Eclipse異常reveal end of document解決辦法

當後臺日誌log太多的時候經常會報Reveal end of document的error,特別是流輸出的時候,所以要特別注意流輸出的時候儘量少使用打印流裏面內容的操作。


public static byte[] encrypt(InputStream in) throws Exception {
        ByteArrayOutputStream bos = new ByteArrayOutputStream();  
        byte[] buffer = new byte[1024*1024];   
        int r;   
        while ((r = in.read(buffer)) > 0) {   
            bos.write(buffer, 0, r);   
            bos.flush();
        }  
        byte[] outBytes = bos.toByteArray();
        logger.info("outBytes={}",outBytes);
        in.close(); 
        bos.close();
        return new Base64().encode(outBytes);
      } 


主要是由於logger.info("outBytes={}",outBytes);會把字節數組打印到控制檯中,導致Reveal end of document錯誤,eclipse的控制檯buffer最大1000000字節,而我

這邊要輸出到控制檯的有3,156,774 字節,超過了eclipse的buffer能裝的下大小,報出了error











發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章