M
moonhkt
Hi All
I have one utf-8, I want split input file into multi UTF-8. Can I
using str.substring to extract string ? When input file have BOM code,
how to remove the BOM code ?
import java.nio.charset.Charset ;
import java.io.*;
import java.lang.String;
public class read_utf {
public static void main(String[] args) {
File aFile = new File("input.txt");
File oFileDetail = new File("input_det.html");
File oFileHeader = new File("input_hdr.html");
File oFileSKU = new File("input_sku.html");
try {
System.out.println("Header");
System.out.println("Detail");
System.out.println("SKU");
String str = "";
BufferedReader in = new BufferedReader(
new InputStreamReader(new FileInputStream(aFile), "UTF8"));
BufferedWriter outh = new BufferedWriter(
new OutputStreamWriter(new FileOutputStream
(oFileHeader),"UTF8"));
BufferedWriter outdet = new BufferedWriter(
new OutputStreamWriter(new FileOutputStream
(oFileDetail),"UTF8"));
BufferedWriter outsku = new BufferedWriter(
new OutputStreamWriter(new FileOutputStream
(oFileSKU),"UTF8"));
while (( str = in.readLine()) != null )
{
System.out.println(str.length());
outh.write(str.substring(1,10));
outh.newLine();
outdet.write(str);
outdet.newLine();
outsku.write(str.substring(167,178));
outsku.newLine();
}
outh.close();
outdet.close();
outsku.close();
} catch (UnsupportedEncodingException e) {
} catch (IOException e) {
}
}
}
I have one utf-8, I want split input file into multi UTF-8. Can I
using str.substring to extract string ? When input file have BOM code,
how to remove the BOM code ?
import java.nio.charset.Charset ;
import java.io.*;
import java.lang.String;
public class read_utf {
public static void main(String[] args) {
File aFile = new File("input.txt");
File oFileDetail = new File("input_det.html");
File oFileHeader = new File("input_hdr.html");
File oFileSKU = new File("input_sku.html");
try {
System.out.println("Header");
System.out.println("Detail");
System.out.println("SKU");
String str = "";
BufferedReader in = new BufferedReader(
new InputStreamReader(new FileInputStream(aFile), "UTF8"));
BufferedWriter outh = new BufferedWriter(
new OutputStreamWriter(new FileOutputStream
(oFileHeader),"UTF8"));
BufferedWriter outdet = new BufferedWriter(
new OutputStreamWriter(new FileOutputStream
(oFileDetail),"UTF8"));
BufferedWriter outsku = new BufferedWriter(
new OutputStreamWriter(new FileOutputStream
(oFileSKU),"UTF8"));
while (( str = in.readLine()) != null )
{
System.out.println(str.length());
outh.write(str.substring(1,10));
outh.newLine();
outdet.write(str);
outdet.newLine();
outsku.write(str.substring(167,178));
outsku.newLine();
}
outh.close();
outdet.close();
outsku.close();
} catch (UnsupportedEncodingException e) {
} catch (IOException e) {
}
}
}