小晒一下,一个残缺初级版音乐切割和组合软件

本文介绍了一个使用Java实现的简单文件切割与合并工具。该工具包含两个主要功能:一是将大文件切割为多个小文件,二是将切割后的小文件重新合并为原始文件。通过图形界面操作,用户可以方便地指定源文件路径、目标文件夹及文件前缀等参数。

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

//切割

package 文件的切割与和;

import java.awt.*;
import java.awt.event.*;
import java.io.*;

public class Test3 implements ActionListener{
Frame frame;
TextField t1,t2;
Button btn1,btn2;
String string,string1;
Panel p1,p2,p3,p4;
Label l1,l2;
public Test3() {
frame = new Frame("把你割成粉碎");
t1 = new TextField(30);
t2 = new TextField(30);
p1 = new Panel();
p2 = new Panel();
p3 = new Panel();
p4 = new Panel();
l1 = new Label("文件读取路径名:");
l2 = new Label("切割到:");
btn1 = new Button("切割吧");
btn2 = new Button("合体");
btn1.addActionListener(this);
btn2.addActionListener(this);
frame.add(p2,"Center");
p2.add(p3,"North");
p3.add(l1);
p3.add(t1);
p2.add(p4,"South");
p4.add(l2);
p4.add(t2);
frame.add(p1,"South");
p1.add(btn1,"West");
p1.add(btn2,"East");
frame.setSize(600,200);
frame.setLocation(200,200);
frame.setVisible(true);
frame.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
public void test3() {
try {
string = t1.getText();
string1 = t2.getText();
FileInputStream fis = new FileInputStream(string);
FileOutputStream fos = null;
byte[] buf = new byte[1024 * 1024];
int len = 0;
int count = 1;
while ((len = fis.read(buf)) != -1) {
fos = new FileOutputStream(string1 + (count++) + ".part");
fos.write(buf, 0, len);
fos.close();
}
fis.close();
} catch (Exception e) {
// TODO: handle exception
}
}
public static void main(String[] args) {
new Test3();
}
public void actionPerformed(ActionEvent e) {
if(e.getSource() == btn1){
test3();
}else if(e.getSource()==btn2){
new Test1();
frame.setVisible(false);
}
}
}

组合


import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;

public class Test1 implements ActionListener {

Frame frame;
TextField t1,t2,t3;
Button btn2;
String string,string1;
Panel p1,p2,p3;
Label l1,l2,l3;
int i;
public Test1() {
frame = new Frame("超级赛亚人");
t1 = new TextField(20);
t2 = new TextField(20);
t3 = new TextField(5);
p1 = new Panel();
p2 = new Panel();
p3 = new Panel();
btn2 = new Button("合体吧");
btn2.addActionListener(this);
l1 = new Label("文件来源:");
l2 = new Label("存入路径和名称(MP3格式):");
l3 = new Label("文件数:");
frame.add(p1,"Center");
p1.add(p2,"North");
p1.add(p3,"South");
p2.add(l1);
p2.add(t1);
p2.add(l3);
p2.add(t3);
p3.add(l2);
p3.add(t2);
frame.add(btn2, "South");
frame.setSize(600, 200);
frame.setLocation(200, 200);
frame.setVisible(true);
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
public void test1() {
try {
string = t1.getText();
string1 = t2.getText();
i = Integer.parseInt(t3.getText());

ArrayList<FileInputStream> al = new ArrayList<FileInputStream>();
for (int x = 1; x < i+1; x++)
al.add(new FileInputStream(string+x+".part"));
final Iterator<FileInputStream> it = al.iterator();
Enumeration<FileInputStream> en = new Enumeration<FileInputStream>() {
public boolean hasMoreElements() {
return it.hasNext();
}
public FileInputStream nextElement() {
return it.next();
}
};
SequenceInputStream sis = new SequenceInputStream(en);
FileOutputStream fos = new FileOutputStream(string1);
byte[] buf = new byte[1024 * 4];
int len = 0;
while ((len = sis.read(buf)) != -1) {
fos.write(buf, 0, len);
}
fos.close();
sis.close();
} catch (Exception e) {
// TODO: handle exception
}
}
public static void main(String[] args) {
new Test1();

}

@Override
public void actionPerformed(ActionEvent e) {
if(e.getSource() == btn2){
test1();
}

}
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值