Witam, mam problem z taką konwersją pliku. Może ktoś mi pomóc? Z góry dziękuję.
import java.io.*;
import java.nio.*;
import java.nio.channels.*;
import java.nio.charset.*;
import java.nio.file.Paths;
public class Encoding {
public static void main(String[] args) {
Encoding();
}
public static void Encoding(){
String file = System.getProperty("user.home") + "/6.txt";
Charset inpcs = Charset.forName("Cp1250");
Charset outcs = Charset.forName("UTF-8");
FileChannel fc = FileChannel.open(Paths.get(file), READ, WRITE);
ByteBuffer buf = ByteBuffer.allocate((int)fc.size());
fc.read(buf);
buf.flip();
CharBuffer cb = inpcs.decode(buf);
buf = outcs.encode(cb);
fc.write(buf);
fc.close();
}
}