public static void main(String[]args){ FileInputStream fis=null; FileOutputStream fos=null; //输入 try { fis = new FileInputStream("java.txt"); //输出 fos = new FileOutputStream("file"+ File.separator +"login.txt"); //选取字节 byte[]arr=new byte[5]; int temp; try { //进行判断,read(arr)字节数量!,只要不等于-1,则显示全部数据 while((temp = fis.read(arr)) != -1){ fos.write(arr,0,temp); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); //单独体 }finally { try { //关流 fos.close(); fis.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }