I am evaluating different data from a textfile in a rather large algorithm. If the text file contains more than datapoints (the minimum I need is sth. like 1.3 million datapoints) it gives the following error: When I’m running it in Eclipse with the following settings for the installed jre6 (standard VM…
Tag: java
How do I test the JavaMailSender of Spring
I have a service that has injected the JavaMailSender. My service configures it and sends a mail. I’d like to intercept the raw mail to ensure the information is the correct. I’d like to do that in a JUnit. How would you guys do that? Answer I’ve done it using GreenMail. Take a look at my bl…
Count Character Consecutively in Java
I’m trying to write a method that returns the number of times char c first appears consecutively in s, even if it’s a single occurrence of the character. Even spaces break the consecutive count. So …
Can an array be used as a HashMap key?
If a HashMap’s key is a String[] array: Can you access the map by using a newly created String[] array, or does it have to be the same String[] object? Answer It will have to be the same object. A HashMap compares keys using equals() and two arrays in Java are equal only if they are the same object. If
Maven jersey-multipart missing dependency for javax.ws.rs.core.Response
I seem to have a missing dependency but can’t find the solution… I’ve made sure all jersey versions are identical as answered here. Error: Dependencies used: Code where the error happens: Any ideas? Thanks a lot in advance, Frank Answer Yeah found it! Apparently the dependencies were OK. Add…
Create a Bitmap/Drawable from file path
I’m trying to create a Bitmap or Drawable from existing file path. But setImageBitmap(), setImageDrawable() doesn’t show an image from the path. I’ve printed path with mText and it looks like : /storage/sdcard0/DCIM/100LGDSC/CAM00001.jpg What am i doing wrong? Anyone can help me? Answer Crea…
How to split the string into string and integer in java?
I have the String a=”abcd1234″ and I want to split this into String b=”abcd” and Int c=1234. This Split code should apply for all king of input like ab123456 and acff432 and so on. How to split this kind of Strings. Is it possible? Answer You could try to split on a regular expression …
Tips to prevent deadlocks in java
I am studying java threads and deadlocks, I understand deadlock’s examples but I wonder if there are general rules to follow to prevent it. My question is if there are rules or tips that can be …
Java 7 WatchService – Ignoring multiple occurrences of the same event
The javadoc for StandardWatchEventKinds.ENTRY_MODIFY says: Directory entry modified. When a directory is registered for this event then the WatchKey is queued when it is observed that an entry in the directory has been modified. The event count for this event is 1 or greater. When you edit the content of a fi…
JDBCTemplate set nested POJO with BeanPropertyRowMapper
Given the following example POJO’s: (Assume Getters and Setters for all properties) One can easily query a database (postgres in my case) and populate a list of Message classes using a BeanPropertyRowMapper where the db field matched the property in the POJO: (Assume the DB tables have corresponding fie…