Search code examples
javaandroidstringbufferedreaderstringbuilder

Issue when convert buffer to string with hexadecimal code of LF


I am trying to download web page with all its resources . First i download the html, but when to be sure to keep file formatted and use this function below . there is and issue , i found 10 in the final file and when i found that hexadecimal code of the LF or line escape . and this makes troubles to my javascript functions .

Example of the final result :

<!DOCTYPE html>10<html lang="fr">10 <head>10    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />10  

Can someone help me to found the real issue ?

public static String  scanfile(File file) {
        StringBuilder sb = new StringBuilder();
        try {
            BufferedReader bufferedReader = new BufferedReader(new FileReader(file));

            while (true) {
                String readLine = bufferedReader.readLine();
                if (readLine != null) {
                    sb.append(readLine);
                    sb.append(System.lineSeparator());
                    Log.i(TAG,sb.toString());
                } else {
                    bufferedReader.close();
                    return sb.toString();
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }
    }

Solution

  • Actually, there is no problem in this function I was mistakenly adding 10 using another function in my code .