/**
* 读取text文件内容 * @param textsrc * @return * @throws IOException */ public String readFile(String textsrc) throws IOException{ File myFile=new File(textsrc); if(!myFile.exists()) { System.err.println("Can't Find " + textsrc); } BufferedReader in = null; try { in = new BufferedReader(new FileReader(myFile)); } catch (FileNotFoundException e) { e.printStackTrace(); } String str=""; while ((str = in.readLine()) != null) { return str; }
in.close(); return str; } } |
|
来自: 々心寒々 > 《JAVA基础知识》