[Android] File Stream Read / Write
try { // Save File FileOutputStream fos = openFileOutput("test.txt", Context.MODE_WORLD_READABLE); String str = "<maintag>\r\n" + "<System>\r\n" + "<EcoServerIP>192.168.1.10</EcoServerIP>\r\n" + "<DataTestType>1</DataTestType>\r\n" + "</System>\r\n" + "</maintag>"; fos.write(str.getBytes()); fos.close(); Toast.makeText(EcoAgent.this, "input test", 0).show(); } catch(Exception e) { } |
File Read
try { // Load File
FileInputStream fis = openFileInput("test.txt"); byte[] data = new byte[fis.available()]; while(fis.read(data) != -1) {;} fis.close(); Toast.makeText(EcoAgent.this, (new String(data)), 0).show(); } catch(Exception e) { } |