- 论坛徽章:
- 0
|
/**
* @(#)FileStream.java
*
*
* @author
* @version 1.00 2008/3/18
*/
import java.io.*;
public class FileStream {
public static void main(String [] args) {
File f = new File("hello.txt");
try{
//FileOutputStream out = new FileOutputStream(f);
FileWriter out =new FileWriter(f);
//byte buf[]="www.it315.org".getBytes();
//out.write(buf);
out.write("www.it315.org");
out.close();
}
catch(Exception e) {
System.out.println(e.getMessage());
}
try{
//FileInputStream in = new FileInputStream(f);
FileReader in = new FileReader(f);
byte [] buf =new byte[1024];
int len = in.read(buf);
System.out.println(new String(buf,0,len));
}
catch(Exception e){
System.out.println(e.getMessage());
}
}
} |
这是一段学习例子,但是,我却如何都无法标以通过.
错误一直如下,实在不知道原因在何处,望大伙指教一二.谢谢.
标以错误如下:
--------------------Configuration: <Default>--------------------
E:\JavaPro\FileStream.java:30: 找不到符号
符号: 方法 read(byte[])
位置: 类 java.io.FileReader
int len = in.read(buf);
^
1 错误
Process completed. |
|
|