텍스트 파일의 일부를 새 텍스트 파일에 복사하려고합니다.스캐너를 사용하여 파일을 읽을 수 없으며 루프에 들어 가지 않습니다.
이것은 내 스캐너 항목을 만드는 방법은 다음과 같습니다
// folder
File vMainFolder = new File(System.getProperty("user.home"),"LightDic");
if (!vMainFolder.exists() & !vMainFolder.mkdirs()) {
System.out.println("Missing LightDic folder.");
return;
}
// file
System.out.println("Enter the source file's name : ");
Scanner vSc = new Scanner(System.in);
String vNomSource = vSc.next();
Scanner vSource;
try {
vSource = new Scanner(new File(vMainFolder, vNomSource+".txt"));
} catch (final java.io.FileNotFoundException pExp) {
System.out.println("Dictionnary not found.");
return;
}
을 그리고 이것은 내가 잠시 구조를 작성하는 방법입니다 다음을 입력 : 프로그램을 실행하면
이while (vSource.hasNextLine()) {
System.out.println("test : entering the loop");
String vMot = vSource.nextLine(); /* edit : I added this statement, which I've forgotten in my previous post */
}
, 그것은 결코 테스트 "인쇄합니다을 고리". 물론
, 내가 테스트하고이 파일이 비어 있지, 그렇게 같은 단어의 목록입니다
a
à
abaissa
abaissable
abaissables
abaissai
내가 뭘 잘못했는지 이해가 안 돼요, 나는이 방법 몇 가지를 사용했습니다 과거의 시간.
파일 이름이 무엇입니까? '~/LightDic /'디렉토리 안에 있습니까? – vidit
출력물을 볼 수 있습니까? – Viacheslav
'System.out.println (새로운 파일 (vMainFolder, vNomSource + ". txt"). getAbsolutePath());'당신을 위해 인쇄 하시겠습니까? – jlordo