zoukankan      html  css  js  c++  java
  • 一些在内存里面操作的流

    package test;
     
     
    import java.io.*;
    import java.sql.SQLClientInfoException;
    import java.text.DateFormat;
    import java.text.ParsePosition;
    import java.text.SimpleDateFormat;
    import java.util.*;
    import java.util.concurrent.CountDownLatch;
    import java.util.zip.InflaterInputStream;
     
    import javax.annotation.processing.FilerException;
    import javax.management.RuntimeErrorException;
    
    import privateclass.Filterby_Name;
    import privateclass.Filterby_hidden;
    import privateclass.Filterby_java;
    import privateclass.MyBufferedReader;
    import privateclass.Person;
     
    public class Main {
     
        private static final String space_operator = " ";
        private static final double pi = Math.PI;
        private static final String LINE_SEPARATOR = System.getProperty("line.separator");
    	private static final int SIZE = 1024*1024;
    
    
        public static void main(String[] args) throws Exception {
    
        	/*
        	 * 这些在内存里操作的流都不用关闭流
        	 * 也就是close
        	 * 因为关闭无效
        	 *
        	 */
        	ByteArrayInputStream bais = new ByteArrayInputStream("a.sdasasa".getBytes());
        	ByteArrayOutputStream baos = new ByteArrayOutputStream();
        	
        	int ch = 0;
        	while((ch = bais.read()) != -1)
        	{
        		baos.write(ch);
        	}
    
        	
        	System.out.println(baos.toString());
        	
        	
        	char buf[] = new char[1024];
        	buf[0] = '3';
        	CharArrayReader car = new CharArrayReader(buf);
        	CharArrayWriter caw = new CharArrayWriter();
        	while((ch = car.read()) != -1)
        	{
        		caw.write(ch);
        	}
        	System.out.println(caw);
    
        	
        	String s = "3366";
        	StringReader sr = new StringReader(s);
        	StringWriter sw = new StringWriter();
        	
        	while((ch = sr.read()) != -1)
        	{
        		sw.write(ch);
        	}
        	System.out.println(sw);
        }
    
    }
    

      

  • 相关阅读:
    省队集训 Day1 残缺的字符串
    省队集训 Day3 吴清华
    省队集训 Day3 陈姚班
    Java多线程中的join方法
    Java多线程同步机制之同步块(方法)——synchronized
    java-实用的sql语句
    java-分页之页面分页
    java下实现调用oracle的存储过程和函数
    java-MySQL存储过程
    MySQL存储过程
  • 原文地址:https://www.cnblogs.com/WINDZLY/p/11831363.html
Copyright © 2011-2022 走看看