Nothing stands out at me from the code you posted. Does it work for you? What does it not do that you want it to? What is wrong with it?
You might also consider using the Scanner class (see
the API here) instead of the DataInputStream. I think it is a bit easier to use.