이 파일은 매우 기본적인 기능이지만 어떤 이유로 든 bufferedReader/Writer에 문제가 있습니다. 텍스트의 첫 줄을 가져 와서 다른 방법으로 되돌려 놓으려고합니다. 그러나 어떤 이유로 인해 작성자는 임시 파일에 쓰는 것 같지 않고 임시 파일의 이름도 변경하지 않습니다. 내가 알아낼 수 있었던 몇 가지 인쇄 문을 던져txt 파일에서 첫 줄을 지우는 데 문제가 있음
:
- 루프가 제대로
- 를 작동하는 동안 다른 문 올바르게 임시 파일이 쓰기되지
- 을 운영하는 경우 텍스트 파일이 제대로
- 임시 파일이 제대로 이름을 변경하지 않는
- ,369을 던져지는 오류가 없습니다
개인 정적 문자열 wavFinder()는 여기에 내가 사용하고있는 방법입니다 IOException이
String currentWav=null; int x = 1; File inputFile = new File("C:\\convoLists/unTranscribed.txt"); File tempFile = new File("C:\\convoLists/unTranscribedtemp.txt"); BufferedReader reader = new BufferedReader(new FileReader(inputFile)); BufferedWriter writer = new BufferedWriter(new FileWriter(tempFile)); String currentLine = null; while((currentLine = reader.readLine()) != null) { if(x == 1){ currentWav = currentLine; } else{ writer.write(currentLine); } x = 2; } boolean successful = tempFile.renameTo(inputFile); System.out.println("Success: " + successful); System.out.println("currentWav = " + currentWav); return currentWav; }
{
가 발생합니다. 아무 것도 알려주지 않으면 알려주세요. 질문이 있으시면 신속하게 답변 드리겠습니다. 고맙습니다.
작가를 닫았습니까? – Hannes