Is there any Java open source library that supports multi-character (i.e., String with length > 1) separators (delimiters) for CSV? By definition, CSV = Comma-Separated Values data with a single character (‘,’) as the delimiter. However, many other single-character alternatives exist (e.g., tab…
Tag: java
Guava cache and preserving checked exceptions
I’m refactoring some code to use guava Cache. Initial code: In order not to break something I need to preserve any thrown exception as is, without wrapping it. Current solution appears somewhat ugly: Is there any possible way to make it nicer? Answer Just after writing the question started thinking abou…
Java: Rotating Images
I need to be able to rotate images individually(in java). The only thing I have found so far is g2d.drawImage(image, affinetransform, ImageObserver ). Unfortunately, I need to draw the image at a specific point, and there is no method with an argument that 1.rotates the image separately and 2. allows me to se…
declare multiple arraylists
is it possible to declare 2 array lists in the same line? e.g: Is it then possible to do something like: Obviously, I get a compile error when I do the above, and was wondering how could one declare 2 lists in the same line. Answer If you want that, you should do:
Retrieve test name on TestNG
Can I retrieve currently running test name like in JUnit (using getName() or rules)? P.S. I don’t want use some self-written tool based on stack traces. Answer According the to TestNG documentation at: http://testng.org/doc/documentation-main.html you can implement listeners that might be able to help y…
Android Resources Class Memory Usage
I’m making modifications to the Android 4.0 launcher and I have been running into many OutOfMemoryErrors. Since the 4.0.3 update it got much worse (or started, it seems before it was fine, but I never got to test properly) and I have tried many many things to fix it. The error is also in the stock launc…
Java Delay/Wait
How do I delay a while loop to 1 second intervals without slowing down the entire code / computer it’s running on to the one second delay (just the one little loop). Answer
How does Java deal with multiple conditions inside a single IF statement
Lets say I have this: Now. Is Java smart enough to skip checking bool2 and bool3 if bool1 was evaluated to false? Does java even check them from left to right? I’m asking this because i was “sorting” the conditions inside my if statements by the time it takes to do them (starting with the ch…
Java visitor pattern instead of instanceof switch
In this question it is said I can use visitor pattern instead of a bunch of instanceofs. Jmg said “If you are not free to change A, B, and C, you could apply the visitor pattern to achieve the same.” As far as I understand I still have to make A, B and C support visitor (have an accept() method,
Different names of JSON property during serialization and deserialization
Is it possible: to have one field in class, but different names for it during serialization/deserialization in Jackson library? For example, I have class “Coordiantes”. For deserialization from JSON want to have format like this: But when I will serialize object, result should be like this one: I …