Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*; //imports the Buffered Writer
- public class main{ //main
- public static void main(String[] args)throws IOException{
- Writer output = null; //initializes the Writer
- String text = "Example Write"; //Used for an example of how to write to file.
- File file = new File("write.txt"); //creates a file with the file name using the object "file"
- output = new BufferedWriter(new FileWriter(file)); //creates a buffered writer called output
- output.write(text); //uses the output object to write the example text to file.
- output.close(); //clearing memory and closing file.
- System.out.println("Your file has been written"); //Unimportant
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment