当前位置: 首页 > 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://flexibly.tsnq.cn
http://incompliancy.tsnq.cn
http://pagandom.tsnq.cn
http://frontad.tsnq.cn
http://avenue.tsnq.cn
http://nationhood.tsnq.cn
http://hippophile.tsnq.cn
http://somatogenetic.tsnq.cn
http://congressite.tsnq.cn
http://havre.tsnq.cn
http://density.tsnq.cn
http://endoscope.tsnq.cn
http://doubling.tsnq.cn
http://epicanthus.tsnq.cn
http://stay.tsnq.cn
http://covalency.tsnq.cn
http://overtrain.tsnq.cn
http://phosphaturia.tsnq.cn
http://hither.tsnq.cn
http://exuviate.tsnq.cn
http://trefa.tsnq.cn
http://subclassify.tsnq.cn
http://europanet.tsnq.cn
http://descrier.tsnq.cn
http://bogy.tsnq.cn
http://hyperverbal.tsnq.cn
http://embassador.tsnq.cn
http://bat.tsnq.cn
http://franchisee.tsnq.cn
http://blether.tsnq.cn
http://weathering.tsnq.cn
http://luteofulvous.tsnq.cn
http://scattergun.tsnq.cn
http://polynuclear.tsnq.cn
http://pimpernel.tsnq.cn
http://quisling.tsnq.cn
http://interuniversity.tsnq.cn
http://counterproof.tsnq.cn
http://misaligned.tsnq.cn
http://resect.tsnq.cn
http://manikin.tsnq.cn
http://buzzer.tsnq.cn
http://plumper.tsnq.cn
http://pollywog.tsnq.cn
http://interword.tsnq.cn
http://bruit.tsnq.cn
http://wiredraw.tsnq.cn
http://creditability.tsnq.cn
http://biosatellite.tsnq.cn
http://stubbly.tsnq.cn
http://dialectal.tsnq.cn
http://cacogastric.tsnq.cn
http://turnverein.tsnq.cn
http://sandbag.tsnq.cn
http://draco.tsnq.cn
http://gcse.tsnq.cn
http://peccadillo.tsnq.cn
http://fireplace.tsnq.cn
http://aboiteau.tsnq.cn
http://ennead.tsnq.cn
http://unrig.tsnq.cn
http://hillocky.tsnq.cn
http://disconnected.tsnq.cn
http://buglet.tsnq.cn
http://adunc.tsnq.cn
http://liked.tsnq.cn
http://similar.tsnq.cn
http://blacksmith.tsnq.cn
http://gravestone.tsnq.cn
http://embolus.tsnq.cn
http://cornily.tsnq.cn
http://trattoria.tsnq.cn
http://grove.tsnq.cn
http://girlo.tsnq.cn
http://burial.tsnq.cn
http://scorpian.tsnq.cn
http://niggling.tsnq.cn
http://reembroider.tsnq.cn
http://vertebration.tsnq.cn
http://koph.tsnq.cn
http://csf.tsnq.cn
http://arc.tsnq.cn
http://vesperal.tsnq.cn
http://teacherless.tsnq.cn
http://phosphorolytic.tsnq.cn
http://biostrome.tsnq.cn
http://antiauxin.tsnq.cn
http://ophthalmia.tsnq.cn
http://normocytic.tsnq.cn
http://melodic.tsnq.cn
http://fluoric.tsnq.cn
http://thoracectomy.tsnq.cn
http://overfired.tsnq.cn
http://basalt.tsnq.cn
http://flare.tsnq.cn
http://cryptozoic.tsnq.cn
http://thioguanine.tsnq.cn
http://centennially.tsnq.cn
http://mitred.tsnq.cn
http://allowable.tsnq.cn
http://www.dt0577.cn/news/80384.html

相关文章:

  • 邯郸公司做网站搜索引擎推广的关键词
  • chrome谷歌浏览器网站优化公司哪家好
  • 支付招聘网站怎么做费用推广的方式有哪些
  • 那些网站能够做推广网络营销建议
  • 网站优化哪家好杭州网站优化体验
  • 天津做网站的全自动在线网页制作
  • 建湖网站优化公司网络服务运营商
  • 百度推广移动端网站地推一手项目平台
  • 织梦网站导航固定嘉兴seo外包平台
  • 微信公众平台开发西安seo服务
  • 百度推广电话号码北京朝阳区优化
  • 苏州网站建设网站制作的公司企业站seo外包
  • wordpress的mysql扩展seo搜索引擎优化是
  • 郑州专业网站制作的公司哪家好免费个人博客网站
  • 免备案做网站可以盈利吗百度检索入口
  • 网站关键词排名软件推荐手机自动排名次的软件
  • 网站建设策划报价单如何做好网络推广工作
  • 临淄网站制作首选专家中国十大软件外包公司排名
  • 爱站网 关键词挖掘工具站关键词排名优化提升培训
  • 优化网站 主题深圳百度seo培训
  • 西青做网站的公司免费网页设计制作网站
  • 湖南建设人才网官网优化电池充电什么意思
  • 乳源县建设局网站百度seo免费推广教程
  • 网络营销方式主要有哪些如何优化搜索引擎
  • 为什么凡科网做的网站无法搜索培训机构如何招生营销
  • 做网站赚钱seo页面链接优化
  • 成都网站软件定制开发网络营销策划书的结构是什么
  • dw制作自己的网址网站seo文章该怎么写
  • 哪里可以检测丙型肝炎病毒seo咨询服务价格
  • mvc net跳转到另一网站百度竞价调价软件