zoukankan      html  css  js  c++  java
  • 2019.6.12Java/IO data

    import java.util.*;
    import java.io.*;
    public class IOTest {
    	
    	public static void main(String[]args){
    		File file = new File("d:\data.txt");
    		try{
    			FileOutputStream out = new FileOutputStream(file);
    			 byte str[] = "12345abcdef@#%&*软件工程".getBytes();
    			 out.write(str);
    			 out.close();
    		}catch(Exception e){
    			e.printStackTrace();
    		}
    		try{
    			FileInputStream in = new FileInputStream(file);
    			byte str[] = new byte[1024];	
    			int len = in.read(str);
    			System.out.println("文件中的信息是:"+new String(str,0,len));
    		}catch(Exception e){
    			e.printStackTrace();
    		}
    		File file1 = new File("d:\data.txt");
    	    //显示与文件有关的属性信息
    	    System.out.println("文件或目录是否存在:" + file1.exists());
    	    System.out.println("是文件吗:" + file1.isFile());
    	    System.out.println("是目录吗:" + file1.isDirectory());
    	    System.out.println("名称:" + file1.getName());
    	    System.out.println("绝对路径:" + file1.getAbsolutePath());
    	    System.out.println("文件大小:" + file1.length());
    
    	}
    }
    
    

  • 相关阅读:
    KMP算法
    Java中的字段和属性
    Java的垃圾回收机制
    一个初学所了解的jquery事件
    jQuery选择器
    hide(1000)跟show(1000)
    show/hide
    点击消失功能
    Java中集合Set的用法
    oracle的nvl和sql server的isnull
  • 原文地址:https://www.cnblogs.com/BKKITO/p/11008303.html
Copyright © 2011-2022 走看看