200字范文,内容丰富有趣,生活中的好帮手!
200字范文 > Android开发之复制图片到另一个文件夹

Android开发之复制图片到另一个文件夹

时间:2022-12-26 17:22:32

相关推荐

Android开发之复制图片到另一个文件夹

/***图片的复制操作方法* @param fromFile 被复制的图片* @param toFile 复制的目录图片*/public static void copyfile(File fromFile, File toFile){if(!fromFile.exists()){return;}if(!fromFile.isFile()){return;}if(!fromFile.canRead()){return;}if(!toFile.getParentFile().exists()){toFile.getParentFile().mkdirs();}if(toFile.exists()){toFile.delete();}try {FileInputStream fosfrom = new FileInputStream(fromFile);FileOutputStream fosto = new FileOutputStream(toFile);byte[] bt = new byte[1024];int c;while((c=fosfrom.read(bt)) > 0){fosto.write(bt,0,c);}//关闭输入、输出流fosfrom.close();fosto.close();} catch (FileNotFoundException e) {e.printStackTrace();} catch (IOException e) {e.printStackTrace();}}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。