Skip to Main Content

New to Java

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!

write to file in ansi

807597Sep 13 2005 — edited Sep 14 2005
I want to write an arraylist to a text file and have the file encoded in ansi. I have found the only way to have the file encoded in ansi is to write strings to the file. I can't figure out how to cast my arraylist to strings, (which is what i think I must do).

Any help/suggestions are appreciated. Below is my code:

import java.io.*;

//This class writes the status to the Master.txt file upon radio button press
class Writer1{
public Writer1(){

System.out.println("writer1 has been called");

try {

OutputStream bout = new BufferedOutputStream(fout);

OutputStreamWriter out = new OutputStreamWriter(bout,"ASCII");

for(int i = 0; i < Chat6.arrList.size(); i++) {
//out.write(Chat6.arrList.get(i)) + "\n");//need to convert to string

}

System.out.println("writing array loop " +Chat6.arrList);

out.flush();
out.close();
} catch (IOException e) {

}
}
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 12 2005
Added on Sep 13 2005
6 comments
1,329 views