文件流输出的例子

 

import java.io.*; public class FileInputStreamDemo { public static void main(String args[]) throws Exception{ int size; InputStream f = new FileInputStream("FileInputStreamDemo.java"); System.out.println("Total Available Bytes: "+ (size = f.available())); int n = size/40; System.out.println("First "+n+" bytes of the file one read() at a time"); } } 

上面代码报错。。。

 

Exception in thread "main" java.io.FileNotFoundException: FileInputStreamDemo.java (系统找不到指定的文件。)

at java.io.FileInputStream.open(Native Method)

at java.io.FileInputStream.(Unknown Source)

at java.io.FileInputStream.(Unknown Source)

at FileInputStreamDemo.main(FileInputStreamDemo.java:5)

 

进行如下改动之后可以正常运行。。。 InputStream f = new FileInputStream("src/FileInputStreamDemo.java");

你可能感兴趣的:(学习总结,exception,thread,import,string,class,file)