zoukankan      html  css  js  c++  java
  • java IO 流的学习(我们到底能走多远系列1)

    我们到底能走多远系列(1)

    “我们到底能走多远系列”:开始我的java之路。我要挖出这个地道,离开这里。

    IO入门代码阅读:

    字节流:

        private void writeTxt(String path, String value) throws IOException{
            OutputStream fos = new FileOutputStream(path);//构造方法1
            fos.write(value.getBytes());
            fos.close();
        }
        private void readTxt(String path) throws IOException{
            File file = new File(path);
            InputStream fis = new FileInputStream(path);//构造方法2
            byte b[] = new byte[(int)file.length()] ;
            fis.read(b);
            System.out.print(new String(b));
            fis.close();
        }

    字符流:

        private void writeTxt(String path, String value) throws IOException{
            Writer writer = new FileWriter(path);
            writer.write(value);
            writer.close();
        }
        
        private void readTxt(String path) throws IOException{
            Reader reader = new FileReader(path);
            char c[] = new char[1024] ;
            int len = reader.read(c);
            System.out.print(new String(c, 0, len));
            reader.close();
        }
  • 相关阅读:
    Docker5之Deploy your app
    Docker4之Stack
    Docker3之Swarm
    Docker之Swarm
    Docker2之Service
    Docker1之Container
    Nuget EPPlus的使用
    Nuget CsvHelper 的使用
    excel
    Chrome上的扩展工具
  • 原文地址:https://www.cnblogs.com/killbug/p/2640845.html
Copyright © 2011-2022 走看看