Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Read and write a .CSV file contains cirillic characters issue

samme4lifeJan 26 2013 — edited Jan 26 2013
Hi guys,
I am a developer of a web application project which uses Oracle Fusion Middleware technologies. We use JDeveloper 11.1.1.4.0 as development IDE.
I have a requirement to get a .csv file from WLS to application running machine. I used a downloadActinLinsener in front end .jspx in order to do that.
I use OpenCSV library to read and write .csv files.
Here is my code for read and write the .csv file,
-----------------------------------------------
public void dwdFile(FacesContext facesContext, OutputStream out) {


System.out.println("started");
String [] nextLine;

try {
FileInputStream fstream1 = new FileInputStream("Downloads/filetoberead.CSV");
DataInputStream in = new DataInputStream(fstream1);
BufferedReader br = new BufferedReader(new InputStreamReader(in,"UTF-8"));
CSVReader reader = new CSVReader(br,'\n');
//CSVReader reader = new CSVReader(new FileReader("Downloads/ACTIVITY_LOG_22-JAN-13.csv"),'\n');
List<String> list=new ArrayList();
while ((nextLine = reader.readNext()) != null) {

if(nextLine !=null){
for(String s:nextLine){
list.add(s);
}
}
}
System.out.println("list size ; "+list.size());
OutputStreamWriter w = new OutputStreamWriter(out, "UTF-8");
CSVWriter writer = new CSVWriter(w, ',','\u0000');
for(int i=0;i<list.size();i++){
System.out.println("list items"+list.get(i));
String[] entries = list.get(i).split(",");
writer.writeNext(entries);
//System.out.println("list items : "+list.get(i));
}
writer.close();
} catch (IOException e) {
e.printStackTrace();
}

}
-----------------------------------------------

say the filetoberead.CSV contains following data,
-----------------------------------------------
0,22012013,E,E,ASG,,O-0000,O,0000,100
1,111211,LI,0,TABO,B,M002500003593,,,К /БЭ60072715/,КАРТЕНБАЙ
2,07,Balance Free,3
1,383708,LI,0,BDSC,B,НЭ63041374,,,Т /НЭ63041374/,ОТГОНБААТАР
2,07,Balance Free,161
-----------------------------------------------

It reads and writes the numbers and english characters correct. All cirillic characters it prints "?" as follows,
-----------------------------------------------
0,22012013,E,E,ASG,,O-0000,O,0000,100
1,111211,LI,0,TABO,B,M002500003593,,,? /??60072715/,?????????
2,07,Balance Free,3
1,383708,LI,0,BDSC,B,??63041374,,,? /??63041374/,???????????
2,07,Balance Free,161

-----------------------------------------------

can somone please help me to resolve this problem?

Regards !
Sameera
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 23 2013
Added on Jan 26 2013
2 comments
1,083 views