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(); } } }