Created
June 9, 2014 08:32
-
-
Save dsaiztc/31cd90edf9ecd87c40f4 to your computer and use it in GitHub Desktop.
Write to file in Java/Android
This file contains 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
// Save to storage/folder/ | |
File fileDir = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/folder/"); | |
fileDir.mkdirs(); | |
String name = "file.txt"; | |
File mFile = new File(fileDir, name); | |
BufferedWriter writer = null; | |
try | |
{ | |
writer = new BufferedWriter(new FileWriter(mFile, true)); | |
writer.write("something"); | |
} | |
catch (IOException e) | |
{ | |
} | |
finally | |
{ | |
if (writer != null) writer.close(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment