我在从批量文件中读取文本文件时遇到了一些问题。
这是文本文件:
ABCD1
ABCD2
ABCD3
ABCD4
ABCD5
ABCD6
ABCD7
ABCD8
ABCD9 ... etc.
这是批处理文件:
@echo off
:start
Echo.
set java_home="C:\Program Files\Java\jre1.8.0_112"
set /p LocName= <LocName.txt
mkdir c:\CSR\%LocName%\
%JAVA_HOME%\bin\keytool.exe -genkey -keyalg RSA -dname "CN=%LocName%.net, O=AAA, C=US, ST=Georgia, L=Atlanta" -alias V5MACHINE -keypass enterpassword -keystore C:\CSR\%LocName%\V5MACHINE.jks -storepass enterpassword -validity 1461 -keysize 2048
%JAVA_HOME%\bin\keytool.exe -certreq -v -alias V5MACHINE -file C:\CSR\%LocName%\V5MACHINE.csr -keypass enterpassword -storepass enterpassword -keystore C:\CSR\%LocName%\V5MACHINE.jks
echo %Date% %Time% Certification request file for %LocName% stored in C:\CSR\%LocName% >>C:\CSR\Log.txt
Pause
Echo Complete!
答案 0 :(得分:0)
使用import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.DefaultListModel;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JScrollPane;
import javax.swing.WindowConstants;
public class Jlist {
JFrame frame;
JList<String> list;
JButton button;
public Jlist(){
init();
}
public void init(){
frame = new JFrame("Sample");
frame.setSize(300, 300);
frame.setLayout(new BorderLayout(30, 30));
DefaultListModel<String> model = new DefaultListModel<>();
model.addElement("A");
model.addElement("B");
model.addElement("C");
model.addElement("D");
model.addElement("E");
list = new JList<>();
list.setModel(model);
JScrollPane pane = new JScrollPane(list);
pane.setViewportView(list);
button = new JButton("Get");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
buttonActionPerformed();
}
});
frame.add(pane, BorderLayout.NORTH);
frame.add(button, BorderLayout.CENTER);
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
public void buttonActionPerformed(){
for(int i = 0; i< list.getModel().getSize();i++){
System.out.println(list.getModel().getElementAt(i));
}
}
public static void main(String[] args) {
new Jlist();
}
}
循环来解析文件。 for /f
代表每行一行。
%%a