Results 1 to 4 of 4
  1. #1
    icu222much is offline Member
    Join Date
    Mar 2010
    Posts
    6
    Rep Power
    0

    Default Reading Chunks of Data

    I am trying to implement a calculator protocol over a server and I have setted up a client and a server. The client will be sending data to the client such as "CALC ver3 \nValue 54.6" and "OPER ver3 \nOperation: ADD". I am trying to find for the server to read the data while ignoring the \n. At the moment, I have a BufferedReader set up, and I am using the readLine() method to process the input. The problem here is that readLine() considers a line to terminate when it sees the \n which is not what I want. Are there any alternatives to solve my problem?

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Uhm, maybe you should not be using a new line there, or you should simply always read two lines as long as the first line coincides with your "protocol"?

  3. #3
    icu222much is offline Member
    Join Date
    Mar 2010
    Posts
    6
    Rep Power
    0

    Default

    The protocol states that there must be a new line there.

    How would I read two lines at a time instead of one? I am looking through BufferedReader and it seems that my only options are to read one line at a time, or one character at a time.

  4. #4
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    readLine into a String, check that that line "fits" the protocol, and string concatenate with a second readLine?

Similar Threads

  1. Reading Numerical Data
    By tyang in forum New To Java
    Replies: 1
    Last Post: 02-05-2010, 04:19 AM
  2. Replies: 5
    Last Post: 08-21-2009, 12:03 PM
  3. Reading data to file
    By puk284 in forum Advanced Java
    Replies: 1
    Last Post: 04-28-2009, 04:19 PM
  4. continuous playback of chunks
    By arnab321 in forum CLDC and MIDP
    Replies: 0
    Last Post: 12-11-2008, 09:46 PM
  5. Reading Data from a file
    By ramachandran in forum New To Java
    Replies: 2
    Last Post: 10-24-2007, 08:22 AM

Posting Permissions

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