android create zip file with txt files -
i want create zip file txt files. each txt file string. here code
file f = new file("test.zip"); f.mkdirs(); try { zipoutputstream out = new zipoutputstream(new fileoutputstream(f)); out.putnextentry(new zipentry("testfolder/mytext.txt")); byte[] data = stringintxt.tostring().getbytes(); out.write(data, 0, data.length); out.closeentry(); out.close(); } catch (ioexception e) { system.out.println(e.tostring()); }
i filenotfoundexception on
zipoutputstream out = new zipoutputstream(new fileoutputstream(f));
is proper way create zip file txt files? if so, how fix exception?
you must type entire path, including drive letter , filename extension , @ new file("test.zip");
Comments
Post a Comment