2017-05-10 1 views
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(); 

} 
} 
} 
+1

파일이 클래스의 패키지가 아닌 프로젝트의 기본 폴더에 나타나야합니다. 응용 프로그램에서 파일을 만듭니다. 직접 만들 필요는 없습니다. – f1sh

답변

0

파일이 자동으로 만들어지고 프로젝트 루트 폴더에 저장됩니다. 또한 이클립스에서 프로젝트 파일을 볼 수 없다면 프로젝트 탐색기에서 프로젝트를 클릭하고 F5를 누르거나 프로젝트를 마우스 오른쪽 버튼으로 클릭하고 새로 고침을 선택하십시오.

관련 문제