Skip to content

Instantly share code, notes, and snippets.

@Domacoski
Created January 27, 2016 16:18
Show Gist options
  • Save Domacoski/55969e6ddfe86f6c688f to your computer and use it in GitHub Desktop.
Save Domacoski/55969e6ddfe86f6c688f to your computer and use it in GitHub Desktop.
Salvar .txt Android
public class Write {
public static void writeToFile(String data)throws IOException {
FileOutputStream stream = null;
try {
File root = android.os.Environment.getExternalStorageDirectory();
File dir = new File(root.getAbsolutePath() + "/UBI");
dir.mkdirs();
File file = new File(dir, "LOG_GATEWAY.txt");
stream = new FileOutputStream(file, true);
stream.write(data.getBytes());
} finally {
if(null != stream){
stream.close();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment