用JAVA写的电子书切割器 欢迎修改意见至wmm204@126.com

这是一个使用JAVA编写的电子书切割器源代码,通过输入文件名和切割后每个文件的大小进行切割操作。用户界面简单,包括文本字段和按钮。在运行过程中可能会遇到乱码问题,作者期待高手的建议和改进。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 /*下面是电子书切割器源代码 被切割文件要和切割器在同一目录*/import java.awt.*;import java.awt.event.*;import java.io.*;public class TextCut extends Frame implements ActionListener,WindowListener{static TextCut f=new TextCut();static TextField fileName=new TextField("文件名字",20);static TextField fileSize=new TextField("切割后文件大小",20);static Button btn=new Button("开始切割");static String fname=""; static String fsize="";public static void main(String[] args){    f.setSize(200,150);   f.setTitle("my text cut");   f.setLayout(new FlowLayout(FlowLayout.CENTER));   fileName.addActionListener(f);   fileSize.addActionListener(f);   btn.addActionListener(f);                                     f.addWindowListener(f);   f.add(fileSize);   f.add(fileName);   f.add(btn);   f.setVisible(true); }public void textValueChanged(TextEvent e){  }                   public void windowActivated(WindowEvent e) //活动窗口{}public void windowClosed(WindowEvent e) //窗口关闭{}public void windowClosing(WindowEvent e)//按下窗口关闭钮{   f.dispose();   System.exit(0);}public void windowDeactivated(WindowEvent e) //变成非活动窗口{}public void windowDeiconified(WindowEvent e) //窗口还原{}public void windowIconified(WindowEvent e) //窗口最小化{}public void windowOpened(WindowEvent e) //窗口打开{}public void actionPerformed(ActionEvent e){   Button b=(Button)e.getSource();   if(b==btn){   fname=fileName.getText();   fsize=fileSize.getText();   qiege();   }}public static void qiege(){try{     int ch;    int l=Integer.parseInt(fsize);    int len=fname.length();     FileInputStream fin=new FileInputStream(fname);       for(int j=1;j>0;j++)      {      if(fin.read()==-1)   break;           else{        StringBuffer newName=new StringBuffer(fname);        newName.insert((len-4),String.valueOf(j));        String Name=new String(newName);        for(int i=0;i<l;i++){        ch=fin.read();     FileOutputStream fout=new FileOutputStream(Name,true);     fout.write(ch);        }          }          }    }catch(Exception e){}}} 正学到java输入与输出流 就写了这个东西 想挑战下自己从构思到写好花了1星期。高手别笑 ,小弟才学的java。虽然界面还是很粗糙的,可修改的地方也很多,我还是蛮高兴的。切割后会有乱码,是为什么啊?欢迎批评和指点!!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值