首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >io流文本文档的快速读取

io流文本文档的快速读取

作者头像
红目香薰
发布2022-11-28 15:39:09
发布2022-11-28 15:39:09
4830
举报
文章被收录于专栏:CSDNToQQCodeCSDNToQQCode

package com.ute.action; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; /**  *   * @author Administrator  * 文本文档的快速读取  */ public class action { public static void main(String[] args) { Long start=System.currentTimeMillis(); action.teIO();

Long end=System.currentTimeMillis();

System.out.print("用时");

System.out.println(end-start); } public static void teIO(){ //通过反射的方式获取流对象 File file1 = new File(action.class.getResource("utest.txt").getFile()); System.out.println("文件是否存在测试:"+file1.exists());//true FileReader fr = null; try { fr= new FileReader(file1); //修改每次读取的个数,一般为2进制递进64-128-256-512-1024 char [] c=new char[64]; while (fr.read(c) != -1) { System.out.println(c); } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); }finally { try { //关闭读取流 fr.close(); } catch (IOException e) { e.printStackTrace(); } } } }

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2017-10-12,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档