zoukankan      html  css  js  c++  java
  • io流

    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;

    public class iotessd {

    public static void main(String[] args) {
    	File f1=new File("data.text");
    	if(!f1.exists()) {
    		try {
    			f1.createNewFile();
    		}catch(IOException e){
    			e.printStackTrace();
    		}
    	}
    	System.out.println(f1.exists());
    	try {
    		FileOutputStream out=new FileOutputStream(f1);
    		byte buy[]="12345abcdef@#%&*".getBytes();
    		out.write(buy);
    		out.close();
    	}catch(IOException e) {
    		e.printStackTrace();
    	}
    	try {
    		FileInputStream in=new FileInputStream(f1);
    		byte[] byt=new byte[1000];
    		int len=in.read(byt);
    		System.out.println("文件信息:"+new String(byt,0,len));
    		in.close();
    	}catch(IOException e) {
    		e.printStackTrace();
    	}
    }
    

    }
    true
    文件信息:12345abcdef@#%&*

    心得:在对于io流的程序编辑中,了解到了文件的一些处理方法,以及文件路径的·查询方法,我相信这对于我们接下来的电脑应用实践中有很大的发挥空间;另外,通过对程序的设计,我也能更加清晰的知道,要想将所有东西记住很难,但我们必须思考,运用电脑,书籍等资料来查询。

  • 相关阅读:
    Redundant Connection
    Recover Binary Search Tree
    Min Stack
    *Flatten Binary Tree to Linked List
    Copy List with Random Pointer
    Binary Tree Maximum Path Sum
    Arithmetic Slices
    Integer to English Words
    Unique Email Addresses
    Mycat(水平拆分--分表 全局序列)
  • 原文地址:https://www.cnblogs.com/javalv/p/11027396.html
Copyright © 2011-2022 走看看