Answer the question
In order to leave comments, you need to log in
JAVA, why doesn't filewriter write anything to notepad?
I want to write a short message to the desktop in notepad, it doesn't work. It's still empty.
Public class Record{
public static void main(String[] args) {
try {
String data = "Получилось!";
FileWriter fWriter = new FileWriter("C:\\Users\\handi\\OneDrive\\Рабочий стол\\новый.txt");
fWriter.write(data);
}
catch ( IOException e ) {
e.printStackTrace();
}
Answer the question
In order to leave comments, you need to log in
fWriter.close()
Forgot to add.
There is another better way (Java 7+):
try (FileWriter fWriter = new FileWriter("C:\\Users\\handi\\OneDrive\\Рабочий стол\\новый.txt")) {
String data = "Получилось!";
fWriter.write(data);
} catch (IOException e) {
e.printStackTrace();
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question