我有以下代码用于上传文件并将其存储在JTable
private void jLabel1MouseReleased(java.awt.event.MouseEvent evt) {
try {
chooser = new JFileChooser();
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
chooser.showOpenDialog(null);
File directory = chooser.getSelectedFile();
String filename = chooser.getSelectedFile().getName();
if (directory != null && directory.isDirectory()) {
File[] subFiles = directory.listFiles();
for (int i = 0; i < subFiles.length; i++) {
DefaultTableModel model = (DefaultTableModel) filelist.getModel();
model.addRow(new Object[]{filename, subFiles[i]});
}
ReadDocument rf = new ReadDocument();
String text = rf.checkReadOnlyPath(path);
viewdoc.setText(text);
}
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
这个代码用于调用方法tokenizer,之后我想从JTable
中的行中获取文件doc,docx或pdf来进行标记,然后将其存储在另一个JTable
中。
private void jLabel16MouseReleased(java.awt.event.MouseEvent evt) {
Tokenizer tokenizer;
tokenizer = new Tokenizing();
String output = "";
while (tokenizer.hasMoreTokens()) {
output = output.replaceAll("[~!?.@#$%^:;&\\-*,/\\\\`'\"=()_+|\\d]|<J>.*</J>|[\\t\\r]{2,}\"]", "");
output = output.toLowerCase();
output += "\n" + tokenizer.nextToken();
}
}