Skip to content

Tag: java

Java – using recursion to create all substrings from a string

The following code in Java uses recursion to create all possible substrings from a string. I am wondering is there a better way of coding this? I want to use recursion. FAQ Q – Why do I want to do this using recursion? A – Because the CEO of StackOverflow says recursion is important http://www.joe…

Wildcard pattern for RoutingAppender of Log4j2

I am trying to use the new RoutingAppender of Log4j2 to route the different logs based on the MDC (ThreadContext in Log4j2). What I want to do is the following: If MDC map has $contextId -> Append to $contextId appender (specific log) If MDC does not have $contextId -> Append to main appender (general l…

Android: Image upload to web-service loses EXIF data

Please help, I currently upload an image to my web-service which does have the EXIF data attached to it at time of upload. When it arrives on the server, it is minus it’s exif data. Before I upload the image, it’s stored to the devices SD card to which is then decoded using the BitmapFactory class…

Read directory inside JAR with InputStreamReader

So, this question has been asked a million times i believed and I’ve been reading them for a couple of hours and trying several options given by some people but none of them work for me. I want to list all the files inside a directory inside the application’s JAR, so in IDE this works: That gives …

Make immutable Java object

My goal is to make a Java object immutable. I have a class Student. I coded it in the following way to achieve immutability: My question is, what is the best way to achieve immutability for the Student class? Answer Your class is not immutable strictly speaking, it is only effectively immutable. To make it im…