public static String readFile(String file , boolean...isTrims) {
StringBuffer buffer = new StringBuffer();
String code = getJavaEncode(file);
BufferedReader fr;
boolean isTrim = isTrims.length > 0 ? isTrims[0] : false;
String line_separator = System.getProperty("line.separator") ;
try {
String myCode = code != null && !"".equals(code) ? code : "UTF-8";
InputStreamReader read = new InputStreamReader(new FileInputStream(
file), myCode);
fr = new BufferedReader(read);
String line = null;
int flag = 1;
while ((line = fr.readLine()) != null ) {
if(!isTrim){
if (flag != 1) {
buffer.append( line_separator );
}
}
flag++;
//buffer.append( isTrim ? Helper.checkNull(line):line) ;
buffer.append( isTrim ? false:line) ;
}
fr.close();
} catch (Exception e) {
}
return buffer.toString();
} |
|