就10分了 问个io的问题
package test;
import java.io.*;
public class a {
public static void main(String[] args) {
try {
File file = new File( "d:\\Sunset.jpg ");
FileInputStream input = new FileInputStream(file);
BufferedInputStream bufferedinput = new BufferedInputStream(input);
File file2=new File( "e:\\Sunset.jpg ");
FileOutputStream output = new FileOutputStream(file2);
BufferedOutputStream bufferedoutput=new BufferedOutputStream(output);
byte[] zijie = new byte[1024];
while (bufferedinput.available() > 0) { //这里,这什么把bufferedinput.availiable()改成input.available()后 输出的文件是残缺不全的。也是输出的文件只能看到上半部分 下半部分是灰色的。
bufferedinput.read(zijie);
bufferedoutput.write(zijie);
}
bufferedoutput.flush();
bufferedoutput.close();
output.close();
bufferedinput.close();
input.close();
if (file2.exists())
{
System.out.println( "成功! ");
}else{
System.out.println( "失败 ");
}
} catch (Exception ex) {
System.out.println(ex.getMessage());