0
이 프로그램을 작성하여 텍스트 파일에 쓰려고했지만 프로그램을 실행 한 후에 아무 것도 일어나지 않습니다. 파일 경로를 지정하는 방법을 제안 할 수 있습니까? 나는 이클립스를 사용하고 있으며 "out.txt"라는 파일을 내 클래스가있는 동일한 기본 패키지에 만들었습니다.FileOutputStream이 파일에 쓰지 않습니다.
import java.io.*;
public class InputOutput {
public static void main(String args[]) throws IOException
{
int i;
//File file=new File("inputd");
//File file0=new File("out");
FileInputStream fin=null;
//FileOutputStream fout=null;
DataOutputStream fout=null;
//copy the file
try
{
//fin=new FileInputStream("input.txt");
fout=new DataOutputStream(new FileOutputStream("out.txt"));
//fout=new FileOutputStream("out.txt");
fout.write(1);
fout.write(100);
fout.write(1000);
}
catch(IOException ioe)
{
System.out.println("I/O Error" + ioe);
}
finally {
if (fout != null) {
fout.close();
}
//fin.close();
}
}
}
파일이 클래스의 패키지가 아닌 프로젝트의 기본 폴더에 나타나야합니다. 응용 프로그램에서 파일을 만듭니다. 직접 만들 필요는 없습니다. – f1sh