Last active
July 9, 2018 13:31
-
-
Save atechcrew/0d223ea93eb20f6240b0ad8ca627c528 to your computer and use it in GitHub Desktop.
Simple Java Code To Write file. Java Code To Store Data into file. Write File Using java.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.BufferedWriter; | |
import java.io.File; | |
import java.io.FileWriter; | |
public class WriteFile { | |
public static void main(String args[]) { | |
try { | |
/* | |
* Give The Path Of the File to store data. If the file is not found | |
* it will automatically create file with the given name at the given path. | |
* | |
* Remember to give the file extension for example fileName.txt | |
* */ | |
File file_path = new File("file path"); | |
FileWriter file_reader = new FileWriter(file_path); | |
BufferedWriter buff = new BufferedWriter(file_reader); | |
buff.write("This is the data."); | |
buff.close(); | |
}catch(Exception e){ | |
e.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment