Trabla: 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.write( text );
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
2. Eclipse project structure
No comments:
Post a Comment