From cccce01415a93176388f4db2ebd28fd88e4e671f Mon Sep 17 00:00:00 2001 From: Joe Bowser Date: Thu, 15 Oct 2009 13:35:55 -0700 Subject: [PATCH] Changing the Android --- src/com/phonegap/demo/FileUtils.java | 29 ++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/com/phonegap/demo/FileUtils.java b/src/com/phonegap/demo/FileUtils.java index d352c7ab..270e9bf2 100644 --- a/src/com/phonegap/demo/FileUtils.java +++ b/src/com/phonegap/demo/FileUtils.java @@ -92,13 +92,26 @@ public class FileUtils { public int write(String filename, String data) { - try { - FileOutputStream out = new FileOutputStream(filename); - PrintStream p = new PrintStream(out); - p.print(data); - } catch (FileNotFoundException e) { - return -1; - } - return 0; + { + int i=0; + String FilePath="/sdcard/" + filename; + try { + ByteArrayInputStream in = new ByteArrayInputStream(data.getBytes()); + byte buff[] = new byte[1024]; + FileOutputStream out= + new FileOutputStream(FilePath); + do { + int numread = in.read(buff); + if (numread <= 0) + break; + out.write(buff, 0, numread); + System.out.println("numread" + numread); + i++; + } while (true); + out.flush(); + out.close(); + } catch (Exception e) { e.printStackTrace(); } + } + return 0; } }