隐藏页面特效

java文件复制

1|0java文件复制


public static void copy(String startPath,String endPath)throws IOException { long start = System.currentTimeMillis(); //创建读取流 FileInputStream fis = new FileInputStream(startPath); //创建写入流 FileOutputStream fos = new FileOutputStream(endPath,true); //创建读取缓冲流 BufferedInputStream bis = new BufferedInputStream(fis); //创建写入缓冲流 BufferedOutputStream bos = new BufferedOutputStream(fos); //使用缓冲流来读取文件 byte[] bytes = new byte[1024]; int len = 0; while ((len = bis.read(bytes))!=-1){ bos.write(bytes,0,len); } bos.close(); bis.close(); long end = System.currentTimeMillis(); System.out.println("耗时:"+(end-start)); } //播放音频文件 public static void play(String path) throws IOException, JavaLayerException { FileInputStream fis = new FileInputStream(path); BufferedInputStream bis = new BufferedInputStream(fis); Player player = new Player(bis); player.play(); bis.close(); } public static void main(String[] args) throws IOException,JavaLayerException{ copy("./a.mp3","D:/a.mp3"); play("D:/a.mp3"); }

__EOF__

本文作者keep on going,never give up
本文链接https://www.cnblogs.com/-xyk/p/16768387.html
关于博主:评论和私信会在第一时间回复。或者直接私信我。
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角推荐一下。您的鼓励是博主的最大动力!
posted @   彼时听风  阅读(76)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
点击右上角即可分享
微信分享提示