获取项目中.txt 文件的内容


 

package com.fh.controller.ruitai.util;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;

public class TomcatUtil {
    /**
     * @Description  读取文件
     * @author 张洋.
     * @date
     * @return
     * @throws ExceptionFile
     */
    public static String GetIdentified() throws Exception { // 
        File f = new File(TomcatUtil.class.getClassLoader().getResource("tomcatdentified.txt").getPath().replaceAll("%20", " "));
        FileInputStream input = new FileInputStream(f);
        BufferedInputStream buf = new BufferedInputStream(input);
        byte[] b = new byte[(int) f.length()];
        input.read(b);
        input.close();
        String identified=new String(b);
        return identified;
    }
        public static void main(String[] args) {
            try {
                GetIdentified();
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM