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

朝阳做网站哪家公司好关键词工具有哪些

朝阳做网站哪家公司好,关键词工具有哪些,设计上海网站建设,网站建设需要申请服务器吗文件字符流 字符流不同于字节,字符流是以一个具体的字符进行读取,因此它只适合读纯文本的文件,如果是其他类型的文件不适用。 字节流;英文1个字节,中文3个字节。 字符流:中英文都是2个字节 public static…

 文件字符流

字符流不同于字节,字符流是以一个具体的字符进行读取,因此它只适合读纯文本的文件,如果是其他类型的文件不适用。

字节流;英文1个字节,中文3个字节。 字符流:中英文都是2个字节

    public static void main(String[] args){try (FileReader reader = new FileReader("test.txt")){System.out.println((char) reader.read());}catch (IOException e){e.printStackTrace();}try (FileWriter writer = new FileWriter("test.txt")){writer.write("eeee");}catch (IOException e){e.printStackTrace();}//拷贝try (FileReader reader1 = new FileReader("test.txt");FileWriter writer1 = new FileWriter("test1.txt")){char[] chars = new char[3];int len;while ((len=reader1.read(chars))!= -1){writer1.write(chars,0,len);}}catch (IOException e){e.printStackTrace();}}
}

文件对象

    public static void main(String[] args) throws IOException {//文件对象File file = new File("test.txt");System.out.println(file.exists()); //判断文件是否存在System.out.println(file.getAbsoluteFile());  //获取绝对路径file.createNewFile();  //创建文件file.length();  //获取字节长度File file1=new File("hello/test2");System.out.println(file1.mkdirs()); //创建文件夹}
}

    public static void main(String[] args){File file=new File("Honor(1).mp3");try (FileInputStream in = new FileInputStream("Honor(1).mp3");FileOutputStream out =new FileOutputStream("xxx.mp3")){byte[]bytes=new byte[1024*1024];int len;long total =file.length(),sum=0;while ((len=in.read(bytes))!=-1){out.write(bytes,0,len);sum+=len;System.out.println("文件已拷贝"+(sum*100/total)+"%");}}catch (IOException e){e.printStackTrace();}}/*输出
文件已拷贝10%
文件已拷贝21%
文件已拷贝31%
文件已拷贝42%
文件已拷贝52%
文件已拷贝63%
文件已拷贝73%
文件已拷贝84%
文件已拷贝95%
文件已拷贝100%
*/

缓冲流

当调用mark()之后,输入流会以某种方式保留之后读取的readlimit数量的内容,当读取的数量超过readlimit则之后的内容不会被保留,当调用reset()之后,会使得当前的读取位置回到mark()调用时的位置。

        try (BufferedInputStream stream = new BufferedInputStream(new FileInputStream("test.txt"))){stream.mark(0);System.out.print((char) stream.read());System.out.print((char) stream.read());System.out.println((char) stream.read());stream.reset();System.out.print((char) stream.read());System.out.print((char) stream.read());System.out.print((char) stream.read());System.out.print((char) stream.read());}catch (IOException e){e.printStackTrace();}

转换流

读取的是一个字符串或一个个字符,但是只能往一个OutputStream里输出,但是OutputStream只支持byte类型,如果要往里面写入内容,进行数据转换就会很麻烦,可以使用转换流使之简洁:

        try (OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream("test.txt"))){writer.write("aaabbbbccc");}catch (IOException e){e.printStackTrace();}

同样的,现在只拿到一个InputStream,希望能按照字符否方式读取:

        try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream("test.txt")))){System.out.println(reader.readLine());}catch (IOException e){e.printStackTrace();}

http://www.dtcms.com/wzjs/228469.html

相关文章:

  • 开淘宝店和自己做购物网站哪个好搜索引擎环境优化
  • 怎么做网赌网站网站的推广方法
  • 网站打开是别人的新闻稿发布软文平台
  • 做相片网站白杨seo教程
  • wordpress简单的工单提交百度地图排名可以优化吗
  • 零食性网站建设策划书百度推广广告收费标准
  • 免版权图片网站seo综合查询
  • 深圳网站建设公司排行榜seo优化推广
  • 内网网站 建设目标全国seo公司排名
  • 开源saas多用户建站系统百度指数数据分析
  • 做网站的公司合肥营销和销售的区别
  • 春节网页设计主题seo是什么岗位的缩写
  • 做外贸网站格式乐陵市seo关键词优化
  • 如何获取免费域名成都网络优化托管公司
  • 网站 多个ip 备案最新营销模式有哪些
  • 业网站建设电商数据网站
  • 网站的查询系统怎么做阿里云盘资源搜索引擎
  • 弹性盒子做微网站天津seo管理平台
  • 广州平台网站搭建国产免费crm系统有哪些
  • 怎么选择五屏网站建设1000个关键词
  • 清空wordpress数据库站长之家seo查询
  • 网站登录窗口怎么做seo工具查询
  • 成都最新官方消息优化推广
  • 慈溪网站建设企业网站网页设计
  • 哪个网站可以免费学设计快速排名怎么做
  • 个人网站制作模板图片百度收录网站多久
  • 大学生活动网站开发文案武汉百度
  • 韶关市网站建设公司seo排名教程
  • 济南优化推广网站seo太原seo
  • 随州公司做网站广州网站优化平台