Skip to content

URL decoding: UnsupportedEncodingException in Java

What I understand from the documentation is that UnsupportedEncodingException can only be thrown if I specify a wrong encoding as the second parameter to URLDecoder.decode(String, String) method. Is it so? I need to know cases where this exception can be thrown. Basically, I have this code segment in one of m…

opencsv in java ignores backslash in a field value

I am reading a csv file using opencsv. I am ignoring the first line of; the csv file is tab separated with some values enclosed in double quotes. The problem occurs when I read the values of a column that has the ” character, this is stripped out of the value. For example in original file: It becomes as…

Java heap space in a looped function

Hi I have a java application that is processing a number of records from a database. Now after processing about a 160 of these the java runs throws a “OutOfMemoryError: Java heap space”. Due to this I updated the entire function in order to only process 150 records at one go, which works fine when…

RetentionPolicy CLASS vs. RUNTIME

What is the practical difference between RetentionPolicy.CLASS and RetentionPolicy.RUNTIME? It looks like both are recorded into the bytecode and both may be accessed at the run-time anyway.

Java Scanner String input

I’m writing a program that uses an Event class, which has in it an instance of a calendar, and a description of type String. The method to create an event uses a Scanner to take in a month, day, year,…