Write data in a file. A re-useable component which can be used across the projects.
private void writeToFile(){
try{
String exactFilePath = "give the path where the file has to be made(Destination Directory/Folder)";
//exactFilePath = /DeskTop/DataFile/WriteToFile.txt
String writeInFileData = "Hello this is Mohit and I want to write some Data in a File";
byte[] writeToFileBytes = writeInFileData.getBytes("UTF-8");
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(exactFilePath,true));
bos.write(writeToFileBytes);
bos.flush();
bos.close();
}
catch(Exception fex){
fex.printStackTrace();
}
}