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?
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"?
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.
readLine into a String, check that that line "fits" the protocol, and string concatenate with a second readLine?