文章标题

来源:互联网 发布:厦门市公安局网络公章 编辑:程序博客网 时间:2024/05/21 09:55

package lq20170409;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class Demo1 {
public static void main(String[] args) {
//函数的调用
}
/**
* byte=8bits
* 1kpbs=1024b/s
* @param source 源文件
* @param path 目标文件
* @param bitMs 比特率(可选中文件,右击鼠标在详细信息中查看)kpbs
* @param start 开始的秒数
* @param off 结束的秒数
*/
public void copyMusic(String source,String path,int bitMs,int start,int off){
BufferedInputStream bis=null;
BufferedOutputStream bos=null;
try {
bis=new BufferedInputStream(new FileInputStream(source));
bos=new BufferedOutputStream(new FileOutputStream(path,true));
byte [] b=new byte[1024];
int len;
int startB=start*bitMs*1024/8;
int end=off*bitMs*1024/8;
int sum=0;
while((len=bis.read(b))!=-1){
sum+=len;
if(sum>startB&&sum

0 0
原创粉丝点击