public String readData( String path ) {
StringBuffer str = new StringBuffer( "" );
try {
File file = new File( path );
if (file.isFile() && file.exists()) {
InputStreamReader read = new InputStreamReader( new FileInputStream( file ) );
BufferedReader bufferedReader = new BufferedReader( read );
String lineTXT = null;
while ( ( lineTXT = bufferedReader.readLine() ) != null ) {
str.append( lineTXT.toString() + "\n" );
}
read.close();
} else {
System.out.println( "找不到指定的文件!" );
}
} catch ( FileNotFoundException e ) {
e.printStackTrace();
} catch ( IOException e ) {
e.printStackTrace();
}
return str.toString();
}
读取文件