DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    May 2004
    Posts
    7

    Cool readLine deprecated

    When I use the following I get a warning that readLine is deprecated...

    Code:
    in = socket.getInputStream();
    DataInputStream din = new DataInputStream(in);
    String serverStatus = din.readLine();
    What should I use instead..?

    I tried BufferedReader but was told that "The constructor BufferedReader(InputStream) is undefined"

    Thanks
    Of all the things I've lost in my life, its my mind I miss the most.

  2. #2
    Join Date
    May 2004
    Posts
    7

    Possible answer..?

    I've come up with the following..

    Code:
    DataInputStream in = new DataInputStream(new BufferedInputStream(socket.getInputStream()));
    BufferedReader din = new BufferedReader( new InputStreamReader(in));
    String serverStatus = din.readLine();
    any comments..?
    Of all the things I've lost in my life, its my mind I miss the most.

  3. #3
    Join Date
    May 2004
    Posts
    219
    Code:
    in = new BufferedReader(
    	new InputStreamReader(
    		sock.getInputStream()));
    
    nextLine = in.readLine();

  4. #4
    Join Date
    Feb 2004
    Posts
    808
    w3rd..

    a reader is for text
    an inputstream is for anything

    to convert an inputstream into a reader, you must use InputStreamReader

    a similar analogue of OutputStreamWriter exists that will turn anything you write() or print() to a Writer (such as PrintWriter) into something suitable for sending down an OutputStream
    The 6th edict:
    "A thing of reference thing can hold either a null thing or a thing to any thing whose thing is assignment compatible with the thing of the thing" - ArchAngel, www.dictionary.com et al.
    JAR tutorial GridBag tutorial Inherited Shapes Inheritance? String.split(); FTP?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links