发布时间:2025-12-09 21:17:03 浏览次数:4
**
**
主方法
cut方法体
/** fis = 输入流对象* bt = 歌曲的比特率* start = 裁剪的起始时间* end = 裁剪结束时间* fos = 输出流对象* */public static void cut(FileInputStream fis,int bt,int start,int end,FileOutputStream fos) throws IOException { // 计算开始截取的字节int sta = bt*start*1024/8;//计算结束截取的字节int en = bt*end*1024/8;//定义接收到几个字符长度变量len和total累加器int len,total = 0;//定义接收字节的byte数组byte[] bz = new byte[1024];while ((len = fis.read(bz))!=-1){//累加接收到的个数total += len;//判断字节是否小于要截取的字节数if(total<sta)continue;//判断字节是否大于要截取的字节数,大于则跳出循环if(total>en)break;//将bz数组中的字节输出到fosfos.write(bz,0,len);}System.out.println("裁剪完成");}