Change Encoding to UTF-8
package com.zdiv.jlib.app.CharConv;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import org.apache.commons.io.IOUtils;
public class CharConv {
public static void main(String[] args) {
String directory = "d:\\Ebook\\가림토txt\\객주\\";
File dir = new File(directory);
if( dir.exists() ) {
File[] files = dir.listFiles();
for( File f : files ) {
if( ! f.isDirectory() ) {
String outFileName = f.getAbsolutePath() + ".out";
System.out.println(outFileName );
try {
String dataStr = IOUtils.toString(new FileInputStream(f), "CP949");
byte[] dataByte = dataStr.getBytes("UTF-8");
Files.write(Paths.get(outFileName), dataByte, StandardOpenOption.CREATE);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
}
댓글 없음:
댓글 쓰기