Utils class: compression string gzip

Categories: ANDROID like

import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.zip.GZIPInputStream; import java.util.zip.GZIPOutputStream; public class Compression { public static byte[] compress(String paramString) throws IOException { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(paramString.length()); GZIPOutputStream gzipOutputStream = new GZIPOutputStream(byteArrayOutputStream); gzipOutputStream.write(paramString.getBytes()); gzipOutputStream.close(); byte[] bytes = byteArrayOutputStream.toByteArray(); byteArrayOutputStream.close(); return bytes; } public static String decompress(byte[] paramArrayOfByte) throws IOException { ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(paramArrayOfByte); […]

Reading plain text file in java and android asset

Categories: ANDROID like

//read lines from file ArrayList<String> lines = new ArrayList<String>(); try { BufferedReader input = new BufferedReader(new FileReader(f)); String line; do { if ((line = input.readLine()) != null) lines.add(line); } while (line != null); } catch (IOException e) { e.printStackTrace(); } return lines; //read lines from file asset StringBuilder sb = new StringBuilder(); try { BufferedReader […]

Change time in genymotion emulator – simple java app

Categories: NON ANDROID like

I made app in executable jar java file for setting time in genymotion emulator. Here is simple java code and compiled app for setting time in genymotion app. Below code I showed how the app looks like and also added ready jar app to download. Code: public class SetTimeInGenyMotion { private JTextField textField1; private JButton […]