Created
December 27, 2013 00:59
-
-
Save daichan4649/8140977 to your computer and use it in GitHub Desktop.
テキスト内容をファイル出力 (Android)
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
public class DebugUtil { | |
private static final String DIRPATH_DEFAULT = "/mnt/sdcard/debug"; | |
private static final String FILENAME_DEFAULT = "tmp.txt"; | |
public static void flushText(String text) { | |
String path = String.format("%s/%s", DIRPATH_DEFAULT, FILENAME_DEFAULT); | |
flushText(text, path); | |
} | |
public static void flushText(String text, String filePath) { | |
File file = new File(filePath); | |
FileOutputStream fos = null; | |
OutputStreamWriter osw = null; | |
try { | |
fos = new FileOutputStream(file); | |
osw = new OutputStreamWriter(fos); | |
osw.write(text); | |
} catch (FileNotFoundException e) { | |
} catch (IOException e) { | |
} finally { | |
if (osw != null) { | |
try { | |
osw.close(); | |
} catch (IOException e) { | |
} | |
} | |
if (fos != null) { | |
try { | |
fos.close(); | |
} catch (IOException e) { | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment