Eclipse에서 실행할 때 잘 작동하는 프로그램이 있습니다 (프로그램이 텍스트 파일에서 읽음). 그러나 명령 행에서이를 준수하고 실행할 때 읽는 텍스트 파일을 찾을 수 없습니다. 자바를 사용하여 명령 파일에서 파일을 읽을 수 있습니다
private void openfile()
{
try
{
file = new Scanner(new File("file.txt"));
}
catch(Exception e)
{
System.out.println("i hate command prompt");
}
private void readfile()
{
while(file.hasNext())
{
map_name = file.nextLine().split("\\s+");
}
}
private void closefile()
{
file.close();
}
사람은
File 문서에 지정된대로 내가이
텍스트 파일이 수업과 같은 디렉토리에 있습니까? –