java uses or overrides a deprecated API error

Those are not errors, they are warning, your code compiled.

To explain these lines :

Note: uses or overrides a deprecated API.

You are doing a call of DataInputStream#readLine which is deprecated since JDK 1.1 as per the documentation :

This method does not properly convert bytes to characters. As of JDK 1.1, the preferred way to read lines of text is via the BufferedReader.readLine() method. Programs that use the DataInputStream class to read lines can be converted to use the BufferedReader class by replacing code of the form:

DataInputStream d = new DataInputStream(in);   


BufferedReader d = new BufferedReader(new InputStreamReader(in));

As for the second line :

Note: Recompile with -Xlint:deprecation for details.

It simply tells you the option to use when compiling to get more details about where you are using deprecated stuff.

Edit :

As per your comment, here how your code would looks like :

import;//Add these two imports
BufferedReader br = new BufferedReader(new InputStreamReader(bis));//Use BufferedReader as suggested by the doc instead of DataInputStream
String s = br.readLine();//Read with the non-deprecated readLine of BufferedReader

Leave a Comment