Results 1 to 5 of 5
  1. #1
    mrs_sheep is offline Member
    Join Date
    Apr 2010
    Posts
    6
    Rep Power
    0

    Default cannot find symbol using BufferedReader.read()

    I am reading out of a web page using BufferedReder.read(byte [], int, int) but whatever I enter as byte [] I am told it is "cannot find symbol"

    Java Code:
    BufferedReader reader = new BufferedReader(new InputStreamReader(
                        conn.getInputStream(), "UTF-8"));
    
                byte [] RawData = new byte[conn.getContentLength()];
                int offset = 0;
                int numRead = 0;
                while (offset < RawData.length &&
                        (numRead = reader.read(
                        RawData, offset, RawData.length-offset)) >= 0) {
                    offset += numRead; 
                }
                if (offset < RawData.length) {
                    System.err.println("couldn't complete reading MPEG 3-Layer object");
                }
    Codesample by Reading a File into a Byte Array | Example Depot

    Any ideas? thx .. =D

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,435
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by mrs_sheep View Post
    I am reading out of a web page using BufferedReder.read(byte [], int, int) but whatever I enter as byte [] I am told it is "cannot find symbol"

    Java Code:
    BufferedReader reader = new BufferedReader(new InputStreamReader(
                        conn.getInputStream(), "UTF-8"));
    
                byte [] RawData = new byte[conn.getContentLength()];
                int offset = 0;
                int numRead = 0;
                while (offset < RawData.length &&
                        (numRead = reader.read(
                        RawData, offset, RawData.length-offset)) >= 0) {
                    offset += numRead; 
                }
                if (offset < RawData.length) {
                    System.err.println("couldn't complete reading MPEG 3-Layer object");
                }
    Codesample by Reading a File into a Byte Array | Example Depot

    Any ideas? thx .. =D
    Readers read chars while InputStreams read bytes.

    kind regards,

    Jos

  3. #3
    mrs_sheep is offline Member
    Join Date
    Apr 2010
    Posts
    6
    Rep Power
    0

    Default

    thx a lot now it works ...
    just one more question, why does the error code appear on the "RawData" and not on the ".read(" ? The error even told me that needed parameters were byte [], int, int ?

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,435
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by mrs_sheep View Post
    thx a lot now it works ...
    just one more question, why does the error code appear on the "RawData" and not on the ".read(" ? The error even told me that needed parameters were byte [], int, int ?
    I bet your compiler said something like "read(char[], int, int) can not be applied to the arguments byte[], int, int" while it points you to the start of your argument list (the RawData identifier).

    kind regards,

    Jos

  5. #5
    mrs_sheep is offline Member
    Join Date
    Apr 2010
    Posts
    6
    Rep Power
    0

    Default

    No I'm in NetBeans, the definition came up as the tooltip-warning and on compiling there only popped up "compiling error"

Similar Threads

  1. Can not find symbol ???
    By AliceNewbie in forum New To Java
    Replies: 1
    Last Post: 02-17-2010, 01:44 AM
  2. BufferedReader error cannot resolve symbol
    By SwEeTAcTioN in forum New To Java
    Replies: 12
    Last Post: 10-22-2009, 05:22 AM
  3. cannot find symbol
    By GabWit in forum New To Java
    Replies: 3
    Last Post: 01-25-2009, 12:13 AM
  4. Replies: 9
    Last Post: 10-18-2008, 08:26 PM
  5. Replies: 3
    Last Post: 05-01-2008, 08:30 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •