import java.io.BufferedReader;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.List;
/**
*@Author:jilongliang
*@Date:2013-4-17
*/
public class Test11 {
public static void main(String args[]) throws Exception {
String path="D:\\DATA\\ttt.txt";
// InputStream in = Test11.class.getResourceAsStream(path);
// BufferedReader reader = new BufferedReader(new InputStreamReader(in));
// String line = readLine(2, reader);// 读取第2行
// System.out.println(line);
// reader.close();
List<String> list=getTxtContent(path);
for (int j=3;j<list.size();j++) { ///
System.out.println("第一条:"+list.get(0) );
System.out.println("时间:"+list.get(2) );
System.out.println("联系电话"+list.get(j) );
}
}
private static String readLine(int lineNumber, BufferedReader reader)
throws Exception {
String line = "";
int i = 0;
while (i < lineNumber) {
line = reader.readLine();
i++;
}
return line;
}
/**
* 獲取文本內容
* @param path文件路徑
* 该方法是对文件的哪一行有空的就处理掉,放入一个List里面然后再读第一条数据和时间到
* 一个表的相应字段里面去,而且内容和时间是相同的,联系方式不一样.
*
* @return
*/
public static List<String> getTxtContent(String path){
List<String> content=new ArrayList<String>();
BufferedReader reader = null;
String Line = "";
try {
reader = new BufferedReader(new FileReader(path));
while ((Line = reader.readLine()) != null) {
Line=Line.trim();//去掉空行
if(!Line.equals(""))//不是空的就添加
content.add(Line);
}
} catch (Exception e) {
e.printStackTrace();
}
return content;
}
}