如何在JTable中检索数据并将其存储为另一个JTable以进行标记化?

时间:2015-07-31 15:54:01

标签: java swing jtable tokenize

我有以下代码用于上传文件并将其存储在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();
    }
}        

0 个答案:

没有答案