java怎吗从磁盘读文件_编写一个Java应用程序,该程序使用FileInputStream类,实现从磁盘读取本应用程序源代码文件,并将文件内容显示在屏幕上。...
滿意答案
x78674181
2013.05.10
采納率:42%????等級:12
已幫助:14476人
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.FileNotFoundException;public class Test {
public static void main(String[] args) {
String str="";
BufferedReader br=null;
FileInputStream fis=null;
try {
fis = new FileInputStream("C:/Documents and Settings/Administrator/桌面/Test.java");
br = new BufferedReader(new InputStreamReader(fis));
while((str=br.readLine())!=null) {
System.out.println(str);
}
br.close();
} catch(FileNotFoundException e) {
System.out.println("文件沒有找到");
} catch(IOException e) {
}
}
} 把FileInputStream中的路徑改一下就行了
11分享舉報
總結(jié)
以上是生活随笔為你收集整理的java怎吗从磁盘读文件_编写一个Java应用程序,该程序使用FileInputStream类,实现从磁盘读取本应用程序源代码文件,并将文件内容显示在屏幕上。...的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: kakfa怎么看消息是否堆积_纯种哈士奇
- 下一篇: 移动数据网络类型是nr_便携式移动网络的