I’m looking for a way to extract Zip file. So far I have tried java.util.zip and org.apache.commons.compress, but both gave a corrupted output. Basically, the input is a ZIP file contain one single .doc file. java.util.zip: Output corrupted. org.apache.commons.compress: Output blank file, but with 2 mb …
Tag: java
Where is Java Installed on Mac OS X?
I just downloaded Java 7u17 on Mac OS 10.7.5 from here and then successfully installed it. In order to do some JNI programming, I need to know where Java installed on my Mac. I thought that inside the /Library/Java/JavaVirtualMachines/ folder, there would be a folder called 1.7.0.jdk or something, but then I …
How to improve image rotation quality in Graphics2D?
Currently I am using this code (which I found here) to rotate images in Java. The code works well, but I am not satisfied with the quality of the rotated image. How can I improve it? Do it need a separate library that? Answer You should set RenderingHints.KEY_INTERPOLATION and RenderingHints.KEY_RENDERING as …
Print the type name of object held by variable
In Java, is it possible to print the type of value held by variable? One approach to this problem would be to use an if-statement for each variable type, but that would seem redundant, so I’m wondering if there’s a better way to do this: Answer I am assuming that in case of Animal myPet = new Cat(…
compare two numeric String values
I have a simple doubt. Would be great if anyone helps me. I have two strings: Both the values are equal but how to compare them in java? We have equals and equalsIgnoreCase for comparing String alpha values, similarly how to compare numeric values. Answer That is it. You can convert a numeric string into inte…
How to create a generic launch configuration with Eclipse?
I have a run configuration in my eclipse. In my project we have two branches : DEV and STABLE. I would like to create one run configuration for building my project whatever branch it is on. For now, when I set Base directory with one of those two variables : ${project_path}, ${build_project}, I face this erro…
Download file with original file name
In my project I am uploading a file. While uploading, I am saving its original file name and extension in a database and saving that file with some GUID on server, generated GUID is also stored in database along with file name and extension. For example- -File name for uploading is questions.docx -Then origna…
Android ProGuard settings for Facebook
I finally found out why my app crashes built for release. ProGuard was indeed stripping code from my application but i prevented this by manually adding the classes with the keep command in the proguard-android.txt (found in the sdk). For Facebook I used: But I think I’m still missing something. The app…
How can I get a frame sample (jpeg) from a video (mov)
I want to get a frame sample (jpeg) from a video file (mov) with java. Is there an easy way to do this. When I search in google all I can find is to make mov from multiple jpgs. I dont know maybe I cannot find the right keywords. Answer Xuggler does the job. They even give a sample code
Multiplying two matrices in Java
I am currently developing a class to represent matrices, it represents any general mxn matrix. I have worked out addition and scalar multiplication but I am struggling to develop the multiplication of two matrices. The data of the matrix is held in a 2D array of doubles. The method looks a little bit like thi…