我编写了程序来创建文件并使用 jframe 添加字段,但它无法正常工作,请帮助我,谢谢!
读取文件获取字段全名和客户编号,并使用 jframe 再添加一个字段
全名和客户编号工作正常,但 jframe 无法正常工作.. 所以请帮助我......
实际上我也需要垂直向下滚动,请帮助我..
假设文件中有6条记录..
我需要放入jframe:
00240000844928953504
00240000844928953505
00240000844928953506
00240000844928953507
00240000844928953508
00240000844928953509
文件输出不正确实际上它把所有 6 个扫描仪线放在所有行文件中..
custID,fullname, 00240000844928953504
00240000844928953505
00240000844928953506
00240000844928953507
00240000844928953508
00240000844928953509
custID,fullname, 00240000844928953504
00240000844928953505
00240000844928953506
00240000844928953507
00240000844928953508
00240000844928953509
像这样!!:(
应该是这样的!!
custID,fullname,00240000844928953504
custID,fullname,00240000844928953505
....
这是我的代码!!
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextArea;
public class scanner {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
final JFrame frame = new JFrame("Scan Here: ");
JPanel panel = new JPanel();
final JTextArea text = new JTextArea(20, 40);
JButton button = new JButton("Enter");
frame.add(panel);
panel.add(text);
panel.add(button);
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
BufferedReader br = null;
BufferedWriter lbwp = null;
String scanner = (text.getText());
System.out.println(scanner);
try {
File folderall = new File("FilesIn");
File[] BFFileall = folderall.listFiles();
for (File file : BFFileall) {
String str = file.getName();
String reprintbwletterbwpca = ("FileOut" + "\\" + str);
lbwp = new BufferedWriter(new FileWriter(reprintbwletterbwpca));
lbwp.write("\"CUSTID\",\"FullName\",\"ONECODE\"," + "\n");
br = new BufferedReader(new FileReader(file));
String line;
line = br.readLine();
while ((line = br.readLine()) != null) {
String[] actionID = line.split("\\\",\"");
String custnumber = actionID[3];
String fullname = actionID[18];
String add1 = actionID[19];
lbwp.write("\"" + custnumber + "\",\"" + fullname+ "\"," + "\"" + scanner + "\"," + "\n");
}
lbwp.close();
}
} catch(Exception e1) {
e1.printStackTrace();
}
frame.dispose();
}});
frame.setSize(500, 400);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
请帮我!!