zoukankan      html  css  js  c++  java
  • 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);
    
        }
    }
    
    
  • 相关阅读:
    AngularJS Insert Update Delete Using PHP MySQL
    Simple task manager application using AngularJS PHP MySQL
    AngularJS MySQL and Bootstrap Shopping List Tutorial
    Starting out with Node.js and AngularJS
    AngularJS CRUD Example with PHP, MySQL and Material Design
    How to install KVM on Fedora 22
    Fake_AP模式下的Easy-Creds浅析
    河南公务员写古文辞职信
    AI
    政协委员:最大愿望是让小学生步行上学
  • 原文地址:https://www.cnblogs.com/fxzemmm/p/14847949.html
Copyright © 2011-2022 走看看