I am using a negative number to have fillRect() go the opposite way. It works well on my computer, but my friends cannot see it working properly. What do I do? Answer My guess is that you and your freind are using 2 different versions of Java. your supports fillrect with a negative value and your freind’…
How to reliably guess the encoding between MacRoman, CP1252, Latin1, UTF-8, and ASCII
At work it seems like no week ever passes without some encoding-related conniption, calamity, or catastrophe. The problem usually derives from programmers who think they can reliably process a “text” file without specifying the encoding. But you can’t. So it’s been decided to henceforth forbid fil…
How to start Activity in adapter?
I have a ListActivity with my customized adapter and inside each of the view, it may have some buttons, in which I need to implement OnClickListener. I need to implement the OnClickListener in the adapter. However, I don’t know how to call the function like startActivity() or setResult(). Since the adap…
Operational Transform Implementation (not javascript) [closed]
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations. Closed 6 years ago. Improve this ques…
How to check a uploaded file whether it is an image or other file?
In my web application I have an image uploading module. I want to check the uploaded file whether it’s an image file or any other file. I am using Java in server side. The image is read as BufferedImage in java and then I am writing it to disk with ImageIO.write() How shall I check the BufferedImage, wh…
Comparing XML in java
Here are two XMLs , I am trying to compare and put the respective data in excel sheet. I have a multidimensional array called provisions. AND Now this XML data is for 2 plans and my provisions array contains provisions == [[Plan Features,,][Deductible,,][Individual,,]…..] This is what I have done The pr…
Editing PDF text using Java
Is there a way I can edit a PDF from Java? I have a PDF document which contains placeholders for text that I need to be replaced using Java, but all the libraries that I saw created PDF from scratch and small editing functionality. Is there anyway I can edit a PDF or is this impossible? Answer You can do
Convert RGB values to color name
How can I convert a color in RGB format into a color name? Examples: (0, 0, 255) -> “blue” (255, 0, 0) -> “red” (128, 128, 128) -> “grey” Answer Populate a list of “known” colors. For each known color compute: Return the name of colorI for which rgbDist…
Remove all empty lines
I thought that wasn’t that hard to do, but I want to remove all empty lines (or lines just containing blanks and tabs in Java) with String.replaceAll. My regex looks like this: But it doesn’t work. I looked around, but only found regexes for removing empty lines without blanks or tabs. Answer Try …
How to create your own library for Android development to be used in every program you write?
I am a Delphi programmer and have written, over the years, hundreds of classes and routines which I can use in every Delphi program I write. This library is called dlib and can be used in every Delphi program by putting this folder in my library path and using one of the units in the uses section of a Delphi