怎么使用File/IO复制图片,以下是我写的代码,总是报拒绝访问,请各位哥哥们帮忙看下,谢谢
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
/**
- 使用io流复制图片
- @author Administrator
*
*/
public class IoPicture {
public static void main(String[] args) {
FileInputStream fis=null;
BufferedInputStream bis=null;
FileOutputStream fos=null;
BufferedOutputStream bos= null;
try {
fis=new FileInputStream("D:/Pictures/lzj.jpeg");
bis=new BufferedInputStream(fis);
fos=new FileOutputStream("F:/工作空间");
bos=new BufferedOutputStream(fos);
byte[] bys = new byte[1024];
int len = 0;
while ((len = bis.read(bys)) != -1) {
bos.write(bys, 0, len);
len=bis.read(bys); }
bos.flush(); bos.close(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { try { if(bis!=null){ bis.close(); } if(fis!=null){ fis.close(); } } catch (IOException e2) { // TODO: handle exception e2.printStackTrace(); } } } }