deprecated method

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shaileshkumar
    New Member
    • Aug 2007
    • 36

    deprecated method

    code
    /* creating the object for DatInputStream */
    //DataInputStream din=new DataInputStream (System.in);

    /* calling the readLine() method
    // din.readLine();


    readLine() method of java.io.DataInp utStream is deprecated :my java compiler(jdk1.4 ) says.

    please guide me what is the method that can replace readLine()


    with regards,
    shailesh
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by shaileshkumar
    code
    /* creating the object for DatInputStream */
    //DataInputStream din=new DataInputStream (System.in);

    /* calling the readLine() method
    // din.readLine();


    readLine() method of java.io.DataInp utStream is deprecated :my java compiler(jdk1.4 ) says.

    please guide me what is the method that can replace readLine()


    with regards,
    shailesh
    Download JDK 1.6 and use the Scanner class for reading input. Otherwise, use BufferedReader.

    Comment

    • JosAH
      Recognized Expert MVP
      • Mar 2007
      • 11453

      #3
      If the OP had read the API documentation s/he would have read this:

      Originally posted by API Documentation
      Deprecated. 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:
      [code=java]
      DataInputStream d = new DataInputStream (in);
      [/code]
      with:
      [code=java]
      BufferedReader d
      = new BufferedReader( new InputStreamRead er(in));
      [/code]
      kind regards,

      Jos

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by JosAH
        If the OP had read the API documentation s/he would have read this:



        kind regards,

        Jos
        Big if

        Comment

        • JosAH
          Recognized Expert MVP
          • Mar 2007
          • 11453

          #5
          Originally posted by r035198x
          Big if
          Yep, it's deplorable; I just replied to someone who could just tell us that there
          was 'some error'; too lazy to even copy and paste the compiler error diagnostic.

          kind regards,

          Jos

          Comment

          • r035198x
            MVP
            • Sep 2006
            • 13225

            #6
            Originally posted by JosAH
            Yep, it's deplorable; I just replied to someone who could just tell us that there
            was 'some error'; too lazy to even copy and paste the compiler error diagnostic.

            kind regards,

            Jos
            I replied to that one as well.
            Had to do a lot of gambling too.

            Comment

            Working...