Hello
I'm creating a mobile app to run on a phone and trying to read data from it in the most efficient way. The application will send data to my server app (in the form of bytes, not necessarily characters).
I won't know the length of the data; the end will be marked with a 3 byte marker (i.e. 0x11,0x22,0x33), and then a new set of data will be sent. It is likely that a large amount of data will be sent in each "set" of data. I'm wondering, then, what the most efficient way to read this data is. Should I use InputStreamReader
? BufferedReader
? Obviously, I will need to inspect each character to see if it is part of the marker, and if so, send all the data before the marker to another method for processing.
From what I can tell, BufferedReader.readLine()
would be what I want if my end marker was a \n
(obviously, this is not the case). Do I need to write my own method to read a BufferedReader
byte-by-byte and look for my marker? (I also do not know if this would be the most efficient way?)
I'm new to Java, and socket programming in general, so I appreciate your comments!