• java例程练习(字符流)


    import java.io.*;
    
    public class TestFileReader {
    	public static void main(String[] args) {
    		FileReader fr = null;
    		int c = 0;
    		try {
    			fr = new FileReader("C:/java/Test.java");
    			
    			while((c = fr.read()) != -1) {
    				System.out.print((char)c);
    			}
    			fr.close();
    		} catch (FileNotFoundException e) {
    			System.out.println("找不到指定文件");
    		} catch (IOException e) {
    			System.out.println("文件读取错误");
    		}
    	}
    }
    
    import java.io.*;
    
    
    public class TestFileWriter {
    	public static void main(String[] args) {
    		FileWriter fw = null;
    		
    		try {
    			fw = new FileWriter("C:/java/unicode.txt");
    			for(int c = 0; c <= 50000; c++) {
    				fw.write(c);
    			}
    			fw.close();
    		} catch (IOException e) {
    			System.out.println(e.getMessage());
    			System.out.println("文件写入错误");
    			System.exit(-1);
    		}
    	}
    }
    


  • 相关阅读:
    数据库连接池
    一致性hash
    java 集合大家族
    linkedlist
    HashMap
    hashcode
    Job 逻辑执行图
    CDN
    网站缓存
    Mysql临时文件目录控制
  • 原文地址:https://www.cnblogs.com/wjchang/p/3671703.html
Copyright © 2020-2023  润新知