当前位置: 首页 > news >正文

网站建设报价方案对比安卓系统是谁开发的

网站建设报价方案对比,安卓系统是谁开发的,知名品牌策划公司,百度搜索下载安装1、InputStream与OutputStream 创建两个文件 - 源和目标。然后我们从源创建InputStream并使用OutputStream将其写入目标文件进行 java 复制文件操作。 private static void copyFileUsingStream(File source, File dest) throws IOException {InputStream is null;OutputStr…1、InputStream与OutputStream  创建两个文件 - 源和目标。然后我们从源创建InputStream并使用OutputStream将其写入目标文件进行 java 复制文件操作。 private static void copyFileUsingStream(File source, File dest) throws IOException {InputStream is null;OutputStream os null;try {is new FileInputStream(source);os new FileOutputStream(dest);byte[] buffer new byte[1024];int length;while ((length is.read(buffer)) 0) {os.write(buffer, 0, length);}} finally {is.close();os.close();} } 2、Apache Commons IO FileUtils copyFile(File srcFile, File destFile)可用于在 java 中复制文件。如果您已经在项目中使用 Apache Commons IO那么使用它来简化代码是有意义的。它在内部使用 Java NIO FileChannel因此如果您尚未将其用于其他功能则可以避免使用此包装器方法。下面是使用apache commons io进行java复制文件操作的方法 private static void copyFileUsingApacheCommonsIO(File source, File dest) throws IOException {FileUtils.copyFile(source, dest); } 3、Files类的copy()方法在 java 中复制文件 private static void copyFileUsingJava7Files(File source, File dest) throws IOException {Files.copy(source.toPath(), dest.toPath()); } 4、使用BufferedInputStream/BufferedOutputStream高效字节流进行复制文件 private static void bufferedStreamCopyFile(File srcFile, File desFile) throwsIOException {//使用缓冲字节流进行文件复制BufferedInputStream bis new BufferedInputStream(newFileInputStream(srcFile));BufferedOutputStream bos new BufferedOutputStream(newFileOutputStream(desFile));byte[] b new byte[1024];Integer len 0;//一次读取1024字节的数据while((len bis.read(b)) ! -1) {bos.write(b, 0, len);}bis.close();bos.close(); } 5、使用FileReader/FileWriter字符流进行文件复制 注意这种方式只能复制只包含字符的文件也就意味着你用记事本打开该文件你能够读懂 private static void readerWriterCopyFile(File srcFile, File desFile) throwsIOException {//使用字符流进行文件复制注意字符流只能复制只含有汉字的文件FileReader fr newFileReader(srcFile);FileWriter fw newFileWriter(desFile);Integer by 0;while((by fr.read()) ! -1) {fw.write(by);}fr.close();fw.close();} 6、使用BufferedReader/BufferedWriter高效字符流进行文件复制 意这种方式只能复制只包含字符的文件也就意味着你用记事本打开该文件你能够读懂 private static void bufferedReaderWriterCopyFile(File srcFile, File desFile) throwsIOException {//使用带缓冲区的高效字符流进行文件复制BufferedReader br new BufferedReader(newFileReader(srcFile));BufferedWriter bw new BufferedWriter(newFileWriter(desFile));char[] c new char[1024];Integer len 0;while((len br.read(c)) ! -1) {bw.write(c, 0, len);}//方式二/*String s null;while((s br.readLine()) ! null) {bw.write(s);bw.newLine();}*/br.close();bw.close();} 7、使用BufferedReader/BufferedWriter高效字符流进行文件复制 注意这种方式只能复制只包含字符的文件也就意味着你用记事本打开该文件你能够读懂 private static void bufferedReaderWriterCopyFile(File srcFile, File desFile) throwsIOException {//使用带缓冲区的高效字符流进行文件复制BufferedReader br new BufferedReader(newFileReader(srcFile));BufferedWriter bw new BufferedWriter(newFileWriter(desFile));char[] c new char[1024];Integer len 0;while((len br.read(c)) ! -1) {bw.write(c, 0, len);}//方式二/*String s null;while((s br.readLine()) ! null) {bw.write(s);bw.newLine();}*/br.close();bw.close(); } 8、使用FileChannel复制 Java NIO包括transferFrom方法,根据文档应该比文件流复制的速度更快 private static void copyFileUsingFileChannels(File source, File dest) throws IOException { FileChannel inputChannel null; FileChannel outputChannel null; try { inputChannel new FileInputStream(source).getChannel(); outputChannel new FileOutputStream(dest).getChannel(); outputChannel.transferFrom(inputChannel, 0, inputChannel.size()); } finally { inputChannel.close(); outputChannel.close(); } }
http://www.hkea.cn/news/14340070/

相关文章:

  • 免费网站建设企业沈阳网站优化怎么做
  • 职工之家网站开发新闻稿天津建设工程信息网咨询电话
  • 开源的网站系统临沂建站平台
  • wordpress站点统计小工具nginx设置wordpress伪静态
  • 网站设计制作 建网站建设网站用户名是什么
  • 韶关营销网站开发联系方式WordPress整站搬家插件
  • 哈尔滨网站建设哪家有好看影视大全免费下载安装
  • 南京网站开发南京乐识专心企业网站类型主要包括
  • 医院网站建设的重要性wordpress开发教程
  • 郑州网站建设流程wordpress 有广告插件
  • 做网站都是花钱吗东莞百度网络推广
  • 网站建设的基础常识铜陵做网站的公司
  • iis做外网站点保定关键词排名系统
  • 哪个网站免费h5模板多.net core 做网站
  • vs2015 asp网站开发打开这个网站
  • 成都网站seo服务网站开发采用了哪些技术
  • 大型门户网站建设需要哪些技术和注意事项wordpress完全版教材
  • 做网站优化排名我做微信淘宝客网站有哪些
  • 网站搭建价格表南漳网站设计
  • 网站新版品牌网官网查询
  • 怎样用织梦做音乐网站北京网站建设第一
  • 建设部职业资格注册中心网站中国建设银行手机网站
  • 详细描述建设一个网站的具体步骤营销型网站建设广告语
  • 怎样建设游戏网站八爪鱼采集器WordPress接口
  • 企业网站建设的材料常州模板网站建设咨询
  • 万网的成品网站学生做微商怎么加入
  • 高端公司网站建设网站界面设计试题
  • 网站模板预览与编辑器百度推广长春分公司
  • 一 网站建设的目的与意义网络营销方案例文
  • 为什么企业网站不是开源系统重庆公司做网站