程序是这样的:
import java.io.*;
public class TestdataStream {
public static void main(String arg[]) {
FileInputStream n = null;
FileOutputStream o = null;
DataInputStream d = null;
DataOutputStream dd = null;
int b =0;
char a = '\0';
try {
n = new FileInputStream ("e:/FileCopy.java");
o = new FileOutputStream("e:/File.java");
dd = new DataOutputStream (o);
d = new DataInputStream (n);
while (d.available()>0) {
a=d.readChar();
System.out.println(a);
dd.writeChar(a);
}
dd.flush();
dd.close();
d.close();
}catch (EOFException e) {
e.printStackTrace();
}catch (IOException e) {
e.printStackTrace();
}
}
}
会在d.available()这行报错,而且在输出窗口输出的是乱码,但是看输出的e:/File.java确是对的,这是怎么回事?希望大家帮忙!
Exception in thread "main" java.io.EOFException是什么错误呢?
out.println("hello java!");out.println("你好");*\/ InputStream in1=new FileInputStream("D:\\\\test.txt");BufferedInputStream in2=new BufferedInputStream(in1);DataInputStream in=new DataInputStream(in2);System.out.println(in.readLine());\/*System.out.print(in.readChar()+" ");...
java.io.EOFException at java.io.RandomAccessFile.readChar(RandomAcces...
异常的意思是到达了文件的末尾。就是你到了文件末尾,你仍然要读文件。你贴下代码,你读文件的代码有问题。没有判断是否达到文件末尾,