Skip to content

Instantly share code, notes, and snippets.

@alitamoor65
Created March 29, 2019 05:37
Show Gist options
  • Save alitamoor65/ed73900cee3b6b2e5f98ce00e7c69e4c to your computer and use it in GitHub Desktop.
Save alitamoor65/ed73900cee3b6b2e5f98ce00e7c69e4c to your computer and use it in GitHub Desktop.
A method to write into file, append data to new line each time separated by comma in java
class WriteToFile{
BufferedWriter bw;
public void writeFile1(String number){
File fout = new File(Environment.getExternalStorageDirectory() + "/numbers0300.cvs");
FileOutputStream fos = null;
try {
fos = new FileOutputStream(fout);
bw = new BufferedWriter(new OutputStreamWriter(fos));
bw.write(number + ",");
Log.i(TAG, "writeFile1: " + number);
bw.newLine();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment