I am trying to instantiate a object with BufferedWriter and it wont work. The problem happens when I use the write function. Why won't it let me write to the file? The error is cannot find symbol. Please help me. I know someone knows. Why wont it not find the symbol when this is a bufferedWriter method?
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);
}
}
}