做一个词频统计程序,该程序具有以下功能
基本要求:
(1)可导入任意英文文本文件(2)统计该英文文件中单词数和各单词出现的频率(次数),并能将单词按字典顺序输出。(3)将单词及频率写入文件.
提高要求:完成基本要求的基础上,实现下述功能:1.实现GUI界面。2.将单词及频率写入数据库。
下列程序为提高要求:
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
class TestFrame extends JFrame {
JTextField inputField;
JButton jButton;
static Map<String, Integer> map;
public TestFrame() {
this.setLayout(new FlowLayout());
JPanel jPanel = new JPanel();
inputField = new JTextField(20);
jButton = new JButton("确定");
//为按钮添加事件;
jButton.addActionListener(new ActionListener() {