萌新求指导
萌新求指导 java课老师让把这段代码转换成字符流import 导入FileInputStream类
import 导入FileOutputStream类
import *;//导入io包
public class FileStreamDemo {
public static void main(String[] args) {
int b = 0;
FileInputStream in = null;//声明FileInputStream类的对象in
FileOutputStream out = null;//声明FileOutputStream类的对象out
try { in = new FileInputStream("user1.doc"); //
out = new FileOutputStream("user1.txt");
while((b=in.read())!=-1){
out.write(b); }
in.close();
out.close(); }
catch (FileNotFoundException e) {//文件没有发现异常
System.out.println("找不到指定文件");
System.exit(-1);
}
catch (IOException e1) {
System.out.println("文件复制错误");
System.exit(-1);
}
System.out.println("文件已复制");
}
}