日期:2014-05-20 浏览次数:20848 次
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
public class UTest1 {
public static void main(String[] args) {
BufferedReader br = null;
try {
br = new BufferedReader(new FileReader(new File("1.txt")));
String line = null;
while((line = br.readLine()) != null) {
System.out.println(line);
}
br.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
try {
br.close();
} catch (IOException e1) {
}
}
}
}
public static void main(String[] args) {
StringBuffer sub=new StringBuffer();
BufferedReader br=null;
try {
br=new BufferedReader(new FileReader(new File("f:/1.txt")));
String line=null;
while((line=br.readLine())!=null)
{
sub.append(line+"");
}
String r=sub.toString();
String [] result=r.split("\\
------解决方案--------------------
");
for (int i = 0; i < result.length; i++) {
System.out.println(result[i]);
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block