I am making an HTTP get request to a website for an android application I am making. I am using a DefaultHttpClient and using HttpGet to issue the request. I get the entity response and from this obtain an InputStream object for getting the html of the page. I then cycle through the reply doing as follows: Ho…
Tag: java
what databases can be used with java?
I am doing an undergrad final project, and need to justify my choice of MySQL for the database element of my project. Truth is, it’s the only one I can really use, and hence I went for it. What other database systems could I have used? Any advantages and disadvantages of these over MySQL? Answer In fact…
Compute hex color code for an arbitrary string
Heading Is there a way to map an arbitrary string to a HEX COLOR code. I tried to compute the HEX number for string using string hashcode. Now I need to convert this hex number to six digits which are in HEX color code range. Any suggestions ? Answer If you don’t really care about the “meaningR…
How to create own filetype?
I want to create own filetype to save objects in my app. Basically, I urgently do not need new filetype, but it will be better. I have class. For example Car. It has constructor (String name, String color, int length, Driver driver). When a car is created (its instance), how to save it like a file? Answer To …
Overload with different return type in Java?
Why is it not possible to overload a function just by changing the return type? Will that change in a future version of Java? By the way, just for reference, is this possible in C++? Answer You can’t do it in Java, and you can’t do it in C++. The rationale is that the return value alone is not suf…
How can I do LZW decoding in Java?
I have a database which contains picture data stored as a binary blob. The documentation says the data is encoded using LZW. I thought that I could decode it using the Zip or GZip input streams found in the Java library, but it didn’t work – I got an exception that said the format of the data is n…
How can I upload files to a server using JSP/Servlet?
How can I upload files to server using JSP/Servlet? I tried this: However, I only get the file name, not the file content. When I add enctype=”multipart/form-data” to the <form>, then request.getParameter() returns null. During research I stumbled upon Apache Common FileUpload. I tried this:…
IntelliJ IDEA with Junit 4.7 “!!! JUnit version 3.8 or later expected:”
When I attempt to run the following test in IntelliJ IDEA I get the message: “!!! JUnit version 3.8 or later expected:” It should be noted that this is an Android project I am working on in IntelliJ IDEA 9. The full stack trace looks like this… Answer This problem happens because Android Pla…
Java – ImageIcon won’t show image
I’m trying to load the icon but it won’t show up. The jpanel is within a boxlayout. I don’t know if that messes things up. It’s strange because I can add pretty much anything else except icon images. I went through the debugger and searchIcon is showing the width and height to be -1. D…
make a JLabel wrap it’s text by setting a max width
I have a JLabel which has a lot of text on it. Is there a way to make the JLabel have a max width so that it will wrap the text to make it not exceed this width? Thanks Answer No. You can use HTML in the label, but then you must hard code the break tag. A better approach