在这里,我提出了我在学习 File i/o 时遇到的问题...
import java.io.*;
import java.util.Scanner;
public class UserFILE_IO {
static FileInputStream fin;
static FileOutputStream fout, fout1;
public static void main(String[] args) {
try {
fin = new FileInputStream("ABC.txt");
fout = new FileOutputStream("ABC.txt");
} catch (FileNotFoundException e) {
System.out.println("FILE NOT FOUND!!!");
}
String s;
Scanner sc = new Scanner(System.in);
s = sc.nextLine();
try {
fout.write(s.getBytes());
} catch (IOException e) {
e.printStackTrace();
}
try {
fout.close();
} catch (IOException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}
sc.close();
try {
fout1 = new FileOutputStream("ABC1.txt");
} catch (FileNotFoundException e1) {
e1.printStackTrace();
}
try {
char c;
while ((c = (char) fin.read()) != -1) {
fout1.write(c);
System.out.print(c);
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
fin.close();
fout1.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
现在我面临的问题是,每当我尝试打开
ABC1.txt
来自工作区文件夹(在 C:)中的文件,它显示 12.00 MB 的大小,每当我刷新文件夹时,大小也会每次都增加。我想提的另一件事是,我看不到文件
ABC.txt
在我正在使用的 IDE (Eclipse) 中......我想要解决方案
1)为什么文件 ABC1.txt 的大小大于 12.00 MB +
2)为什么我无法在我的 IDE 中获取 ABC.txt 文件?