⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jmfilechooser.java

📁 梦界家园程序开发基底框架
💻 JAVA
字号:
package jm.framework.gui.module;

import java.io.File;
import java.io.FileInputStream;

import javax.swing.JFileChooser;
import javax.swing.filechooser.FileSystemView;


public class JMFileChooser extends JFileChooser
{
	private static final long serialVersionUID = 5147393060738884154L;
	public static final String CLASS_NAME = "JMFileChooser" ;
    public JMFileChooser()
    {
        super();
    }

    public JMFileChooser(File currentDirectory)
    {
        super(currentDirectory);
    }
    public JMFileChooser(File currentDirectory, FileSystemView fsv)
    {
        super(currentDirectory,fsv);
    }
    public JMFileChooser(FileSystemView fsv)
    {
        super(fsv);
    }
    public JMFileChooser(String currentDirectoryPath)
    {
        super(currentDirectoryPath);
    }
    public JMFileChooser(String currentDirectoryPath, FileSystemView fsv)
    {
        super(currentDirectoryPath,fsv);
    }

    public byte[] getFileBytes(String filePathName) throws Exception
    {
      //byte[]
      byte[] aByte = new byte[0];
      final String sMethod = "getFileBytes";
      try {
        FileInputStream fin = new FileInputStream(new File(filePathName));
        byte[] sor = new byte[2048];

        while ( (fin.read(sor, 0, 2048)) > 0) {
          int ps = sor.length;

          //the mid_step
          byte[] tmp = new byte[aByte.length];
          for (int i = 0; i < aByte.length; i++) {
            tmp[i] = aByte[i];
          }
          //from 0 to mid_length
          aByte = new byte[aByte.length + ps];
          for (int i = 0; i < tmp.length; i++) {
            aByte[i] = tmp[i];
          }
          //from mid_length to max_length
          for (int i = tmp.length; i < aByte.length; i++) {
            aByte[i] = sor[i - tmp.length];
          }
        }
      } //end try()
      catch (Exception e)
      {
        throw new Exception("JMFileChooser." + sMethod, e);
      }
      return aByte;
    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -