Java: write text to file

Trabla: Java: write text to file


Java write text to file


Solving:

1. Source code

package demos;

import java.io.FileWriter;
import java.io.IOException;

public class WriteTextToFileDemo {

public static void main(String[] args) {

String text = "trololololo";

String filePath = "C:\\Users\\samuraikit\\workspace\\demos\\OUTPUT\\WriteTextToFileDemo.txt";

try {

FileWriter writer = new FileWriter(filePath);
writer.writetext );
writer.close();

} catch (IOException e) {
e.printStackTrace();
}

}

}



2. Eclipse project structure


eclipse IDE project structure

No comments:

Post a Comment