BufferedWriter로 개체를 인스턴스화하려고하는데 작동하지 않습니다. 쓰기 기능을 사용하면 문제가 발생합니다. 왜 파일에 쓸 수 없습니까? 오류로 인해 기호를 찾을 수 없습니다. 도와주세요. 나는 누군가가 알고 있음을 안다. 이 심볼이 bufferedWriter 메소드 일 때 왜 심볼을 찾지 못하겠습니까?BufferedWriter 인스턴스가 Java의 txt 파일에 쓰지 않는 이유는 무엇입니까?
package ex5_abcd;
import java.nio.file.*;
import java.io.*;
import static java.nio.file.StandardOpenOption.*;
import java.util.Scanner;
public class EX5_ABCD {
public static void main(String[] args) {
boolean go = true;
String firstN, lastN;
String lineWritten = "";
int IdNum;
Scanner input = new Scanner(System.in);
Path file = Paths.get("C:\\Java\\empList.txt");
try {
OutputStream output = new BufferedOutputStream(Files.newOutputStream(file, CREATE));
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(output));
while (go) {
System.out.println("Please enter Employee's First Name");
firstN = input.nextLine();
System.out.println("Please enter Employee's Last Name");
lastN = input.nextLine();
System.out.println("Please enter " + firstN + " " + lastN);
IdNum = input.nextInt();
lineWritten = IdNum + " " + firstN + " " + lastN;
int lineLength = lineWritten.length();
char [] testChar = new char[1];
testChar [0] = 'a';
writer = write(testChar, 0, lineLength); // Why write error
writer.flush();
writer.newLine();
}
writer.close();
} catch (Exception e) {
System.out.println("Error Msg:" + e);
}
}
}
의 주석 플러시? – JClassic
여전히 형제가 아니며 중복 된 Sotirios Delimanolis는 어디에 있습니까? 나는 그것을보고 싶다. –
@SotiriosDelimanolis 실제 속임수가 아니기 때문에 이것을 없앨 수 있습니까? – JClassic