rt,JTextArea 最大容量是多少?

解决方案 »

  1.   

    JFileChooser fileChooser = new JFileChooser();
    fileChooser.setCurrentDirectory(new File("."));
    fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    int option = fileChooser.showOpenDialog(panel);
    if (option == JFileChooser.APPROVE_OPTION) {
    String pathName = fileChooser.getSelectedFile().getAbsolutePath();
    panel.setFile(new File(pathName));
    panel.getListFilesTextAreaCustomer().setText("");
    FileInputStream fis = null;
    try {
    fis = new FileInputStream(new File(pathName));
    byte[] b = new byte[1024];
    int i = 0;
    int length = 0;
    StringBuffer sb = new StringBuffer();
    do {
    i = fis.read(b);
    length += i;
    if (i >= 0)
    sb.append(new String(b, 0, i));
    //    panel.getListFilesTextAreaCustomer().append(
    //    new String(b, 0, i));
    } while (i != -1);
    panel.getListFilesTextAreaCustomer().setText(sb.toString());
    {
    System.out.println(length);
    System.out.println(
    panel
    .getListFilesTextAreaCustomer()
    .getDocument()
    .getLength());
    }
    } catch (FileNotFoundException e1) {
    //    TODO Auto-generated catch block
    e1.printStackTrace();
    } catch (IOException e1) {
    //    TODO Auto-generated catch block
    e1.printStackTrace();
    } finally {
    if (fis != null)
    try {
    fis.close();
    } catch (IOException e1) {
    //    TODO Auto-generated catch block
    e1.printStackTrace();
    }
    }
    panel.setTextChanged(false);
    }
    } //输出是   6639207
    //5000298