zoukankan      html  css  js  c++  java
  • write写入

    package com.itheima.Demo05Writer;

    import java.io.FileWriter;
    import java.io.IOException;

    /*
    字符输出流写数据的其他方法
    - void write(char[] cbuf)写入字符数组。
    - abstract void write(char[] cbuf, int off, int len)写入字符数组的某一部分,off数组的开始索引,len写的字符个数。
    - void write(String str)写入字符串。
    - void write(String str, int off, int len) 写入字符串的某一部分,off字符串的开始索引,len写的字符个数。
    */
    public class Demo03Writer {
    public static void main(String[] args) throws IOException {
    FileWriter fw = new FileWriter("09_IOAndPropertiesf.txt");
    char[] cs = {'a','b','c','d','e'};
    //void write(char[] cbuf)写入字符数组。
    fw.write(cs);//abcde

        //void write(char[] cbuf, int off, int len)写入字符数组的某一部分,off数组的开始索引,len写的字符个数。
        fw.write(cs,1,3);//bcd
    
        //void write(String str)写入字符串。
        fw.write("传智播客");//传智播客
    
        //void write(String str, int off, int len) 写入字符串的某一部分,off字符串的开始索引,len写的字符个数。
        fw.write("黑马程序员",2,3);//程序员
    
        fw.close();
    }
    

    }

  • 相关阅读:
    PythonStudy——greenlet 协程
    PythonStudy——事件 Event
    PythonStudy——单线程并发的实现
    2015年的总结
    kylin一种OLAP的实现
    分布式消息队列的使用kakfa
    第一次听到了docker
    Hive分布式的数据仓库
    dubbo服务框架学习
    Storm实时计算框架的编程模式
  • 原文地址:https://www.cnblogs.com/hk18181358129/p/13268095.html
Copyright © 2011-2022 走看看