• java Io测试


    package com.Test.Demo.Test;
    
    import java.io.*;
    import java.util.Scanner;
    
    public class IoTest {
        public static void main(String[] args) throws IOException {
            /*File file = new File("E:\Debug\12345\111.txt");
            File file1= new File("E:\Debug\12345\222.txt");
            //文件字节输入输出流
            InputStream inputStream = new FileInputStream(file1);
            OutputStream     stream = new FileOutputStream(file,true); //追加写入
            *//*int b = 0;
            while((b=inputStream.read())!=-1){
                stream.write(b);
            }*//*
            byte[] bytes1 = new byte[10244];
            inputStream.read(bytes1);
            stream.write(bytes1);
            String string = "
    13dwdsdsd";
            byte[] bytes = string.getBytes();
            stream.write(bytes);
            stream.flush();
            inputStream.close();
            stream.close();
            //文件字符输入输出流
            Writer writer = new FileWriter("E:\Debug\12345\444.txt",true);
            Reader reader = new FileReader("E:\Debug\12345\222.txt");
            char[] chars = new char[1000];
            reader.read(chars);
            writer.write(chars);
            writer.flush();
            reader.close();
            writer.close();*/
            //打印字节流
    //        PrintStream printStream = new PrintStream(new FileOutputStream("E:\Debug\12345\444.txt"));
            //今后在输出时,都可以用打印流输出
    //        Scanner scanner = new Scanner(new FileInputStream("E:\Debug\12345\444.txt"));
    //        PrintWriter pri = new  PrintWriter(new FileWriter("E:\Debug\12345\124.txt"));
    //        scanner.useDelimiter("
    ");
    //        while(scanner.hasNext()){
    //            String st=scanner.next();
    //            pri.print(st);
    //        }
    //        pri.flush();
    //        pri.close();
            /*pri.println(1213);
            pri.println("sfsdffs");
            pri.print(new A());*/
    
            //以后读带有空格的数据,可以用以下的格式读取
           /* BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
            String s=bufferedReader.readLine();
            System.out.println(s);
            int t = Integer.parseInt(s);
            System.out.println(t);
            bufferedReader.close();*/
            //以后读不带空格的 扫描流最方便 也可以设置分隔符
            Scanner scanf = new Scanner(System.in);
            scanf.useDelimiter("
    ");
            String  t= scanf.next();
            System.out.print(t);
    
        }
    }
    
    
  • 相关阅读:
    面试中要注意的 3 个 JavaScript 问题
    angularJS遇到的坑
    为什么你的前端工作经验不值钱?
    ceph pg常见的几种状态
    k8s网络之flannel
    k8s流量访问之service
    lvs+keepalived高可用
    iptables【学习笔记】
    Linux和OpenStack中的网络知识【学习笔记】
    服务器BIOS设置
  • 原文地址:https://www.cnblogs.com/fxzemmm/p/14847949.html
Copyright © 2020-2023  润新知