문자 인 코딩 형식 변환

1701 단어 JavaSVN
더 읽 기

package com.yohn.encoding.convert;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileFilter;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;

public class Main {
	public static void main(String[] args) throws Exception {
		String read="E:\\workspace\\gvPayment\\src\\com";
		
		con(read);
	}
	
	private static void con(String read) throws Exception{
		File[]	 files=new File(read).listFiles(new FileFilter() {
			@Override
			public boolean accept(File pathname) {
				if(".svn".equalsIgnoreCase(pathname.getName()))
					return false;
				else
					return true;
			}
		});
		for (File file : files) {
			if(file.isFile()){
				BufferedReader bis=new BufferedReader(new InputStreamReader(new FileInputStream(file), "GBK"));
				StringBuffer sb=new StringBuffer();
				String s=null;
				while((s=bis.readLine())!=null)
				{
					sb.append(s);
					sb.append(System.getProperty("line.separator"));
				}
				bis.close();
				System.out.println(file.getAbsolutePath()+":::::"+sb);
				BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file),"UTF-8"));
				bw.write(sb.toString());
				bw.close();
				sb=null;
			}else{
				con(file.getAbsolutePath());
			}
		}
	}
	
	
}


좋은 웹페이지 즐겨찾기