Replace
DataInputStream dis = new DataInputStream(new BufferedInputStream(is));
With
BufferedReader dis = new BufferedReader(new InputStreamReader(is, "UTF-8"));
Because DataInputStream.readLine()
is deprecated and is discouraged for the following reason:
This method cannot be trusted to convert bytes to characters correctly.
BufferedReader
also has a readLine
method, so the rest of your code should be pretty much unchanged.
Also, whenever you use @SuppressWarnings({ "deprecation" })
I strongly suggest that you be extra careful and make sure you can use the deprecated method despite the warning.