一夜千次狼
记事本文件请看附件
package notepad_read;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Scanner;
public class 读取记事本第一列 {
private static Scanner in;
private static String path = 读取记事本第一列.class.getResource("").getPath();
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
try {
in = new Scanner(new FileReader(path + "20101020.txt"));
} catch (FileNotFoundException e1) {
e1.printStackTrace();
}
while (in.hasNextLine()){
String first_column = in.next(); //只读取第一列
System.out.println(first_column);
java.io.FileWriter fw = new java.io.FileWriter("F:/wangzq_document/project/file_operational/phone.txt", true);
java.io.PrintWriter pw = new java.io.PrintWriter(fw);
pw.println(first_column+"\n");
pw.close();
fw.close();
in.next();
in.next();
in.next();
in.next();
}
}
}
记事本文件请看附件