import java.io.*;
public class TestPrintStreamToReadingFile {
public static void showOut(String str, PrintStream pstr){
try{
BufferedReader br = new BufferedReader(new FileReader(str));
String s = null;
while((s = br.readLine()) != null){
pstr.println(s);
}
br.close();
}catch(IOException ioe){
pstr.println("Can not reading your file");
ioe.printStackTrace();
}
}
public static void main(String[] args) {
String fileName = args[0];
if(fileName != null){
showOut(fileName, System.out);
}
}
}
在执行期间制定文件位置并读取。利用BufferedReader与FileReader
最新推荐文章于 2022-05-11 22:26:43 发布