I am sending requests from a client socket to a server socket, and I want to delimit requests (send as a byte array) using an escape character ("\ n"). I want to have one request per new line Example:
"Request1 " "Request2" "Request3"
To do this, I need to convert "\ n" to byte to compare queries like this
byte[] request= new byte[1024]; int nextByte; while((nextByte=in.read(request))!=DELIMITER) { String chaine = new String( request,0,nextByte); System.out.println("Request send from server: " + chaine); }
The problem is that I get an exception in numeric format when I try to convert "\ n" to byte
private static final byte DELIMITER = Byte.valueOf("\n");
Thank you very much
source share