java中FileReader读取文件

匿名 (未验证) 提交于 2019-12-02 21:35:18
   import java.io.FileNotFoundException; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException;  public class P24 { 	public static void s_readFile(String fName) throws IOException{ 		FileReader r = null; 		 int i=-1; 		 try { 				r = new FileReader(fName);  				while((i= r.read()) != -1) { 					System.out.print((char)i); 				} 	    }finally { 	    	r.close(); 	    } 		  	}  	public static void main(String[] args) { 		final String fName  = "c:/1122.txt"; 		 		try { 			s_readFile(fName); 		} catch (IOException e) { 			e.printStackTrace(); 		} 			 				 	} } 
文章来源: https://blog.csdn.net/qq_43314793/article/details/90054114
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!