Accessing files the right way

While working with files or streams there are many pitfalls on your way.

The first decision is: is the data binary or text?

If you have binary data the handling is straight forward:

InputStream is = ...

InputStream is the way to handle binary data.

But what if you have text data (e.g. a log file you want to read)? Then this is a job for a Reader.

If you now want to read a text the first try is

Reader r = new InputStreamReader(is);

But there is a pitfall with this approach as written in the documentation:

Creates an InputStreamReader that uses the default charset.

The Reader is created with the default charset. When running on different platforms you will have different results. If you access an InputStream that is connected to another computer (e.g. via a network) then you will likely be in trouble because you cannot expect a certain encoding.

To ensure to read the text clearly you must define an encoding and use this explicitly on both sides.

To open a Reader with a certain encoding use

Reader r = new InputStreamReader(is, "UTF-8");

So you can ensure that the data is read with the defined encoding (UTF-8 in this case).

Adding a Web Application to a Jar-File

I had the job to implement the client side of a web service. To test this implementation I needed a server. I could have used a full-blown JEE server and deploy the server-side of the web service there. I decided against this approach (for several reasons).

Another solution for me would be to use the official test server for the web server. This was not feasible because the test server could be down for several reasons (leaving me with searching for bugs that are outside the scope of my duty) and the data was not reliable and changed regularly so that reliable tests were not reproducible.

I decided to deploy my web service as a simple web application to a simple web server (Jetty in my case). Also I wanted a simple way to deploy my test server/service so I decided to embed the Jetty server into a simple application which I can start with a simple script.
Continue reading

Accessing a SSL Protected Web Service with Metro out of a Glassfish Application Server

The Problem

I had the problem to access a web service out of a Glassfish Application Server (3.1.1). Basically this is not a problem because Glassfish (and Metro – the JAX-WS implementation in Glassfish) can handle web services quite well. But in my case there where some problems accessing the web service. My problems were:

  1. The web service has to be accessed via SSL.
  2. The certificate should not be stored in a truststore.
  3. The certificate has not the hostname as the CN.

The first problem is not really a problem but with the second problem together with the first one can be really tough to solve. So lets solve this problems ;-).
Continue reading

Time Away

It was not possible for me to blog for some time now. The reason is that I’ve changed my employer and also had to move. Searching my new job and moving took some time and therefore I had no time to blog. But my next blog entry is nearly finished. I hope that I find some more time to blog in the future.

Developing Android apps with Maven


Now after more than one month my first post in my blog. I hope the time until the next blog will be shorter…

The last weeks I tried to set up an Android project with Maven. I’m using Maven 3.0.3 and use the android-maven-plugin from akquinet. So I generated a new project using the release project template from akquinet (

The project generates without problems inside my NetBeans IDE (I’m still using 7.0.1). When now trying to create a release (without any further configuration except the keystore) the build will fail.
Continue reading

Welcome to my blog

A new blog on the internet… 😉

In this blog I’ll try to give you my insight view to the Java world.

With Java world I mean not only the JSE world but everything else around this e.g. JEE, Scala, Android, Spring and many more.

My goal is to send a post every week or two.

Hope you will enjoy my blog.