// 由绝对路径得到输出流
//path源路径
//fileCopeToPath 目标路径
String path="D:\我的文档\My Pictures\1.jpg ";
String fileCopeToPath=" D:\我的文档\test ";
File file =new File(path);
if(file.exists){
FileInputStream fis = new FileInputStream(file);
FileOutputStream fos= new FileOutputStream( fileCopeToPath+ File.separator +path.subString(path.lastIndexOf("/\"),path.length));
byte[] b = new byte[fis.available()];
int len = 0;
while ((len = fis.read(b)) != -1)
{
fos.write(b, 0, len);
fos.flush();
}
fos.close();
fis.close();
}
try {
InputStream in = new FileInputStream(new File("D:\我的文档\My Pictures\1.jpg"));
OutputStream out = new FileOutputStream(new File("D:\我的文档\test\1.jpg"));
byte[] b = new byte[100];
while (in.read(b) != -1) {
out.write(b);
}
in.close();
out.flush();
out.close();
} catch (Exception e) {
e.printStackTrace();
}