package lianxi; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; /* * 拷贝歌曲 */ public class IOputstreamDemo { public static void main(String[] args) { FileInputStream fi=null; FileOutputStream fo=null; try{ fi=new FileInputStream("F:\\音乐&song\\Beyond-真的爱你.mp3"); fo=new FileOutputStream("E:\\123.mp3"); byte[] bt=new byte[1024]; while(fi.read(bt)!=-1){ fo.write(bt); } }catch(IOException e){ throw new RuntimeException("读写文件失败!!!"); } finally{ if(fi!=null){ try { fi.close(); } catch (IOException e) { e.printStackTrace(); } } if(fo!=null){ try { fo.close(); } catch (IOException e) { e.printStackTrace(); } } } } }//听着歌感受编程的力量,那种充满指尖的力量,大家感受一下吧!!!
时间: 2024-10-22 21:30:42