long beginTime = System.currentTimeMillis();
InputStream is = null;
String ret = null;
try {
is = new BufferedInputStream( new FileInputStream(f) );
long contentLength = f.length();
ByteArrayOutputStream outstream = new ByteArrayOutputStream( contentLength > 0 ? (int) contentLength : 1024);
byte[] buffer = new byte[4096];
int len;
while ((len = is.read(buffer)) > 0) {
outstream.write(buffer, 0, len);
}
outstream.close();
ret = outstream.toString();
//byte[] ba = outstream.toByteArray();
//ret = new String(ba);
} finally {
if(is!=null) {try{is.close();} catch(Exception e){} }
}
long endTime = System.currentTimeMillis();
System.out.println("方法1用时"+ (endTime-beginTime) + "ms");
return ret;
}