Wednesday, 15 June 2011

java - file is not creating on SDCARD android -



java - file is not creating on SDCARD android -

hi have below code write file, read , b file , set info in ab.xml file

string filepath1 = "/sdcard/dictionarys/a.txt"; string filepath2 = "/sdcard/dictionarys/b.txt"; string filepath3 = "/sdcard/dictionarys/ab.xml"; seek { file file = new file(filepath3); file.createnewfile(); bufferedreader br1 = new bufferedreader(new inputstreamreader( new fileinputstream(filepath1), utf8), buffer_size); bufferedreader br2 = new bufferedreader(new inputstreamreader( new fileinputstream(filepath2), utf8), buffer_size); fileoutputstream file3 = new fileoutputstream(filepath3); outputstreamwriter out3 = new outputstreamwriter(file3,utf8); bufferedwriter br3 = new bufferedwriter(out3, buffer_size); string scurrentline1, scurrentline2; while ((scurrentline1 = br1.readline()) != null && ((scurrentline2 = br2.readline())!=null)) { string s3 = scurrentline2.substring(scurrentline1.length()); br3.write("<abcd abc=\""+scurrentline1+"\" def=\""+s3.trim()+"\"/> \n"); br3.flush(); i++; } br3.write("<data>\n"); br3.flush(); br3.close(); out3.flush(); out3.close(); file3.close(); } grab (exception e) { e.printstacktrace(); }

but xml file not created on sdcard path..

try getting path way:

environment.getexternalstoragedirectory()

sometimes string path doesn't work , create sure have next permissions added in manifest.

<uses-permission android:name="android.permission.write_external_storage"/>

java android

No comments:

Post a Comment