[文件] FileUtil.java ~ 11KB 下载(0) package com.mingrui.test; import java.io.*; import java.util.Enumeration; import java.util.Vector; import java.awt.*; import java.awt.event.*; import javax.m http://www.szhaoexport.com/linked/20130216.do; edia.rtp.event.NewParticipantEvent; import javax.swing.*; public class Test18_15 extends JFrame{ private int part=2; private File file=null; private File []files=null; //icon private ImageIcon icon_but_fege_right=new ImageIcon("img/fen_ge_right.png"); private ImageIcon icon_but_hebing_ringht=new ImageIcon("img/he_bing_right.png"); private ImageIcon icon_tiaofu=new ImageIcon("img/tiao_fu.jpg"); private ImageIcon icon_but_hebing=new ImageIcon("img/but_hebing.png"); private ImageIcon icon_jl_hebing=new ImageIcon("img/hebing_left.png"); private ImageIcon icon_mr=new ImageIcon("img/mr.png"); //jlabel private JLabel jl_tiaofu=new JLabel(new ImageIcon("img/icon_tiaofu.png")); private JLabel jl_hebing=new JLabel(new ImageIcon("img/hebing_left.png")); //jbutton private JButton jb_hebing_right=new JButton("�ϲ�",new ImageIcon("img/he_bing_right.png")); private JButton jb_fege_right=new JButton("�ָ�",new ImageIcon("img/fen_ge_right.png")); private JButton jb_hebing=new JButton("ѡ��Ҫ�ϲ����ļ�",new ImageIcon("img/but_hebing.png")); private JButton jb_fege=new JButton("ѡ��Ҫ�ָ���ļ�",new ImageIcon("img/but_fenge.png")); private JButton jb_zouni=new JButton(new ImageIcon("img/zouni.png")); private JButton jb_zouni1=new JButton(new ImageIcon("img/zouni.png")); //jpanel private JPanel jp_right=new JPanel(); private JPanel jp_bottom_total=new JPanel(); private JPanel jp_left=new JPanel(); private JPanel jp_left_up_hebing=new JPanel(); private JPanel jp_left_up_fenge=new JPanel(); private JPanel jp_left_hebing=new JPanel(); private JPanel jp_left_fenge=new JPanel(); //���� private CardLayout cl=new CardLayout(); //���� private DrawPanel dp_fenge=new DrawPanel(); private DrawPanel dp_hebing=new DrawPanel(); //�����б� private JComboBox jcbo; private String[] str={"2","3","4","5","6"}; private FileSeparate fsp; private FileCombiner fcb; Test18_15(){ super("�ļ��ָ���ϲ�"); super.setIconImage(icon_mr.getImage()); fsp=new FileSeparate(dp_fenge); fcb=new FileCombiner(dp_hebing); jb_fege_right.setBorderPainted(false); jb_hebing_right.setBorderPainted(false); jb_fege_right.setBackground(new Color(2766386)); jb_hebing_right.setBackground(new Color(2766386)); jb_zouni.setBackground(new Color(2766386)); jb_zouni1.setBackground(new Color(2766386)); jcbo=new JComboBox<>(str); jcbo.setBackground(new Color(2981939)); jp_left.setLayout(cl); dp_hebing.setBackground(new Color(14015449)); jp_left.add(jp_left_hebing, "hebing"); jp_left.add(jp_left_fenge,"fenge"); jp_right.setLayout(new GridLayout(2, 1)); jp_right.add(jb_fege_right); jp_right.add(jb_hebing_right); //������ɫ jp_left_up_hebing.setBackground(new Color(2766386)); //jb_hebing.setBackground(new Color(2766386)); jp_left_up_hebing.add(jb_hebing); jp_left_up_hebing.add(jl_hebing); jp_left_up_hebing.add(jb_zouni); jp_left_up_fenge.setBackground(new Color(2766386)); jp_left_up_fenge.add(jb_fege); jp_left_up_fenge.add(jcbo); jp_left_up_fenge.add(jb_zouni1); jp_left_hebing.setLayout(new BorderLayout()); jp_left_fenge.setLayout(new BorderLayout()); jp_left_hebing.add(jp_left_up_hebing,BorderLayout.NORTH); jp_left_hebing.add(dp_hebing,BorderLayout.CENTER); jp_left_fenge.add(jp_left_up_fenge,BorderLayout.NORTH); jp_left_fenge.add(dp_fenge,BorderLayout.CENTER); jp_bottom_total.setLayout(new BorderLayout()); jp_bottom_total.add(jp_left,BorderLayout.CENTER); jp_bottom_total.add(jp_right,BorderLayout.EAST); setLayout(new BorderLayout()); add(jl_tiaofu,BorderLayout.NORTH); add(jp_bottom_total,BorderLayout.CENTER); jb_fege_right.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub cl.show(jp_left, "fenge"); } }); jb_hebing_right.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub cl.show(jp_left, "hebing"); } }); jb_hebing.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub dp_hebing.setStr1("being choose your file"); dp_hebing.repaint(); JFileChooser jfc=new JFileChooser(); jfc.setMultiSelectionEnabled(true); int returnVal=jfc.showOpenDialog(null); if(returnVal==JFileChooser.APPROVE_OPTION){ files=jfc.getSelectedFiles(); } } }); jb_fege.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub JFileChooser jfc=new JFileChooser(); int returnVal=jfc.showOpenDialog(null); //jfc.setMultiSelectionEnabled(true); //jfc.setCurrentDirectory(new File("")); if(returnVal==JFileChooser.APPROVE_OPTION){ file=jfc.getSelectedFile(); } } }); jb_zouni.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub if(files!=null) fcb.setFiles(files); try { fcb.setFile(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } }); jb_zouni1.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub if(file!=null){ fsp.setFileCount(part); fsp.setFile(file); } } }); jcbo.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { // TODO Auto-generated method stub part=jcbo.getSelectedIndex() 2; } }); } public static void main(String[] args) { // TODO Auto-generated method stub Test18_15 frame=new Test18_15(); frame.setSize(600,550); frame.setLocationRelativeTo(null); frame.setDefaultCloseOperation(3); frame.setVisible(true); frame.setResizable(false); } } class DrawPanel extends JPanel{ private Color colorWord; private Color colorLine; private String str="you are being the file function panel"; private String str1="processing......"; private String str2="file location:"; private String str3=""; protected void paintComponent(Graphics g){ super.paintComponent(g); g.setColor(colorLine); g.drawLine(0, 10, getWidth(), 10); g.drawLine(0, 12, getWidth(), 12); g.drawLine(getWidth()-10, 0, getWidth()-10, getHeight()); g.drawLine(0, getHeight()-10, getWidth(), getHeight()-10); g.drawLine(0, getHeight()-8, getWidth(), getHeight()-8); g.drawLine(0, getHeight()-12, getWidth(), getHeight()-12); g.drawLine(0, getHeight()-14, getWidth(), getHeight()-14); g.drawLine(10, 0, 10, getWidth()); g.drawLine(12, 0, 12, getWidth()); g.drawLine(14, 0, 14, getWidth()); g.drawLine(16, 0, 16, getWidth()); g.setColor(new Color(11118449)); g.setFont(new Font("Brush script MT",Font.ITALIC,25)); g.drawString(str, 23, 35); g.setColor(Color.red); g.drawString(str1, 23, 65); g.drawString(str2, 23, 95); g.drawString(str3, 23, 125); g.setFont(new Font("Microsoft YaHei UI",Font.BOLD,15)); g.setColor(Color.green); g.drawString("ע�⣬���ܼ����Ҳ࣬", 23, 248); g.drawString("������ɫ�������в���", 23, 288); g.setColor(Color.orange); g.drawString("ѡ�������Ҫ������ļ��?��С��---����", 23, 328); } public Color getColorWord() { return colorWord; } public void setColorWord(Color colorWord) { this.colorWord = colorWord; } public Color getColorLine() { return colorLine; } public void setColorLine(Color colorLine) { this.colorLine = colorLine; } public void setStr(String str){ this.str=str; } public void setStr1(String str1){ this.str1=str1; } public void setStr3(String str3){ this.str3=str3; } } class FileSeparate{ private int fileCount=0; private int soloFileSize=0; private byte [] buf; private boolean isTxt=false; private static final String OUTFILES="D:"; private DataOutputStream [] doss; DrawPanel dp; //private BufferedWriter [] buw; FileSeparate(DrawPanel dp){ this.dp=dp; } public void setTxt(boolean isTxt){ this.isTxt=isTxt; } public boolean isTxt(){ return isTxt; } public void setFile(File file){ try { doss=new DataOutputStream[fileCount]; this.setFileCount(fileCount); DataInputStream dis=new DataInputStream(new BufferedInputStream(new FileInputStream(file))); int cl=0; if(!isTxt){ int l=dis.available()/1024/1024; soloFileSize=(int)(l/fileCount) 1; if(soloFileSize>=1
转载于:https://www.cnblogs.com/fpqqchao/archive/2013/02/17/2913877.html