本帖最后由 15536889258 于 2015-10-30 14:51 编辑
import java.io.*;
public class Test6
{
public static void main(String[] args)
{
BufferedInputStream bufis = null;
BufferedOutputStream bufos = null;
try
{
bufis = new BufferedInputStream(new FileInputStream(
"c:\\1.jpg"));
bufos = new BufferedOutputStream(new FileOutputStream(
"c:\\2.jpg"));
int byt = 0;
while ((byt = bufis.read()) != -1)
{
bufos.write(byt);
}
}
catch (IOException e)
{
throw new RuntimeException("拷贝失败");
}
finally
{
try
{
if (bufis != null)
bufis.close();
} catch (IOException e)
{
throw new RuntimeException("读取关闭失败");
}
try
{
if (bufos != null)
bufos.close();
}
catch (IOException e)
{
throw new RuntimeException("写入关闭失败");
}
}
}
}
|
|