javabufferedreaderdigital-signaturexml-signatureinputstreamreader

how to read line without skipping end of line character in java using buffered reader


I am using BufferedReader object to read line from HTTP server through FileInputStream. readline() function returns a line skipping end of line character. But my requirement need to read full characters as it will be used to verify the signature. Signature verification fails if any character mismatch from the content. Please help me solve this problems


Solution

  • Could you not just append "\n" onto the end of the string returned from readLine()?

    You could also use the plain "read" method in the BufferedReader class like

    BufferedReader in = new BufferedReader(new FileReader(file));
    
    int ch;
    while((ch = in.read()) != -1) {
       //do processing with (char)ch
    }
    

    This will read every character, without stripping the \n