The Eclipse ADT automatically generates a
R.java
, which keeps track of all the application resources, in hello\gen
as follows: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 {
public class TestImagesss {
public static void main(String[] args) {
BufferedImage org = getImage("test.jpg");
BufferedImage negative = getNegativeImage(org);
new ImageFrame(org, "Original");
new ImageFrame(negative, "After Negative");
public final class HexConvertUtils {
private HexConvertUtils() {
}
public static byte[] toBytesFromHex(String hex) {
public final class FileIOUtility {
private FileIOUtility() {}
public static boolean deleteFile(File fileToDelete) {
if (fileToDelete == null || !fileToDelete.exists()) {
return true;
} else {
public class Lock_Key_Control_In_Java {
public static void main(String[] args) {
Toolkit tk = Toolkit.getDefaultToolkit();
//enable disable key state Caps Lock, Scroll Lock, Num Lock keys
tk.setLockingKeyState(KeyEvent.VK_NUM_LOCK, true);
tk.setLockingKeyState(KeyEvent.VK_CAPS_LOCK, false);
tk.setLockingKeyState(KeyEvent.VK_SCROLL_LOCK, false);
}
}
The lock keys LED in the keyboard should be turned ON or OFF ?
new ImageFrame(inImg, "Input Image ");// inImg is reference to Image object
The code below can be used to load images in JFrame as a separate window.public final class FileIOUtility {
private FileIOUtility() {}
public static void moveFile(File src, File targetDirectory) throws IOException {
if (!src.renameTo(new File(targetDirectory, src.getName()))) {
String str = (new StringBuilder()).append("Failed to move ").append(src).append(" to ").append(targetDirectory).toString();
throw new IOException(str);
} else
String cmd = "cmd.exe /c start ";
String file = "http://www.google.com";
Runtime.getRuntime().exec(cmd + file);