Re: Problem reading/writing U.K. pound sign
Here is my one line test data file
001=A3999.99
Here is my test program code which I am compiling and running on
linux.
import java.io.*;
import java.util.*;
public class poundtesting {
public static void main(String[] args) {
String strReturn;
String strDocumentFile = "/home/john/poundtest";
InputStream fr;
BufferedReader br = null;
try {
fr = new FileInputStream(strDocumentFile);
br = new BufferedReader(new InputStreamReader(fr, "UTF-8"));
}
catch (java.io.FileNotFoundException e) {
strReturn = "FileNotFoundException trying to open " +
strDocumentFile;
System.out.println(strReturn);
}
catch (java.io.UnsupportedEncodingException e) {
strReturn = "FileNotFoundException trying to open " +
strDocumentFile;
System.out.println(strReturn);
}
String s = null;
String outline = null;
do {
try {
s = br.readLine();
if (s != null) {
outline = s;
System.out.println(s);
}
} catch (Exception e) {
strReturn = " Error while reading " + strDocumentFile;
System.out.println(strReturn);
}
} while (s != null);
String strBatchFile = "/home/john/poundout";
OutputStream fw;
BufferedWriter bw = null;
try {
fw = new FileOutputStream(strBatchFile,true);
bw = new BufferedWriter(new OutputStreamWriter(fw, "UTF-8"));
}
catch (java.io.FileNotFoundException e) {
strReturn = "FileNotFoundException trying to open " +
strBatchFile;
System.out.println(strReturn);
}
catch (java.io.UnsupportedEncodingException e) {
strReturn = "FileNotFoundException trying to open " +
strBatchFile;
System.out.println(strReturn);
}
try {
bw.write(outline);
bw.newLine();
} catch (IOException e) {
strReturn = "IOEXception trying to write " + strBatchFile ;
System.out.println(strReturn);
}
try {
br.close();
bw.close();
} catch (Exception e) {
// Don't care
}
}
}