zoukankan      html  css  js  c++  java
  • IO编程__字符流__输入、输出

    一、代码如下

    package www.tainiu.wenjian;
    
    import java.io.FileNotFoundException;
    import java.io.FileReader;
    import java.io.FileWriter;
    import java.io.IOException;
    import java.lang.Character.UnicodeBlock;
    
    public class ae__FileString__V1 {
    
    	public static void main(String[] args) {
    		// TODO Auto-generated method stub
    		FileReader fr= null;
    		FileWriter fw= null;
    		
    		try {
    			fr= new FileReader("d:\Test.txt");
    			fw= new FileWriter("e:\Test.txt");
    			String test= "jst";
    			String test2= "jst讲解";
    			String s= null;
    			
    			char[] chars= new char[1024];
    			int n= 0;
    			while((n=fr.read(chars)) != -1) {
    //				s= new String(chars);
    //				String newString= new String(s.getBytes(), "gbk");
    //				String utf8= new String(newString.getBytes("UTF-8")); 
    //				String gbk1= new String(utf8.getBytes("GBK")); 
    				//String newString_V2= new String(unicode.);
    //				System.out.println(gbk1);
    				//fw.write(chars, 0, n);
    				fw.write(chars);
    //				fw.write(gbk1);
    			
    			}
    			//fw.write(chars);
    			//fw.write(test);
    			//fw.write(test2);
    			
    			
    		} catch (Exception e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		} finally {
    			try {fr.close();fw.close();} catch (Exception e1) {e1.printStackTrace();}
    		}
    
    	}
    
    }
    
  • 相关阅读:
    c#之字段,属性,索引器,常量
    c#类,对象,类成员简介
    c#之接口,依赖反转,单元测试
    c#之 抽象类与开闭原则
    c#重写与多态
    c#之类
    c#之类的继承,类成员的访问控制
    c#之委托
    c# try catch用法思路
    js的全局变量
  • 原文地址:https://www.cnblogs.com/wujianbo123/p/7633135.html
Copyright © 2011-2022 走看看