日期:2014-05-20 浏览次数:20926 次
public static void main(String[] args) { File f = new File("E:\\hwtt\\Test\\src\\Test2.java"); String str = f.getName(); System.out.println(str); Reader reader = null; BufferedReader bufferedReader = null; try { reader = new FileReader(f); bufferedReader = new BufferedReader(reader); while ((str = bufferedReader.readLine()) != null) { System.out.println(str); } } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { if (bufferedReader != null) { try { bufferedReader.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }