![]() |
| Android - Project folder structure |
src: Java Source codes. The Java classes must be kept in a proper package with at least two levels of identifiers (e.g.,com.example...).
AndroidManifest.xmlAndroidManifest.xml in the project's root directory. It descibes the application components.R.java, which keeps track of all the application resources, in hello\gen as follows:
private static void list_of_string_into_text_file_and_zip_them_all(List dataList) throws Exception {
File zipFile = new File("OutputZipFile.zip");
ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipFile));
int count = 0;
for (String string : dataList) {
// repeat for each string
String fileNameInsideZip = ++count + "-inside_text_file.txt";
ZipEntry e = new ZipEntry(fileNameInsideZip);
out.putNextEntry(e);
// write data into zip entry
byte[] data = string.getBytes();
out.write(data, 0, data.length);
out.closeEntry();
}
out.flush();
out.close();
}
public static void main(String[] args) throws Exception {
// store string into text file - and zip them . doesnot create a
// temporary text file.
List test = new ArrayList();
test.add("This is amazing");
test.add("What a wonderful world");
test.add("This is a beautiful day ");
list_of_string_into_text_file_and_zip_them_all(test);
}
For creating a single text file from string and zip it - see this post.
private static void zip_single() throws Exception {
final StringBuilder sb = new StringBuilder();
sb.append("Test String that goes into text file inside zip");
final File f = new File("single_text_file_inside.zip");
final ZipOutputStream out = new ZipOutputStream(new FileOutputStream(f));
ZipEntry e = new ZipEntry("inside_text_file.txt");
out.putNextEntry(e);
byte[] data = sb.toString().getBytes();
out.write(data, 0, data.length);
out.closeEntry();
out.close();
}
public static void main(String[] args) throws Exception {
zip_single();
}
import java.io.IOException;
public class StartBrowserUtil {
private StartBrowserUtil() {
}
public static void openURL(String s) {
String s1 = System.getProperty("os.name").toLowerCase();
Runtime runtime = Runtime.getRuntime();
try {