I have the following code to save an Object to file, the problem is I want to save it as CP1252 and as an object, But it only lets me save as String
BufferedWriter output = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file_path), "Cp1252"));
output.write(object_root.toString());
output.close();
Saving as String gives me problem when loading the Object, that is an ArrayList<StringBuffer>
, to process its content
When I load the object from file it gives me a String, and I cant figure a way to make it an ArrayList<StringBuffer>
again, I tried:
BufferedReader input = new BufferedReader(new InputStreamReader(new FileInputStream(file_path), "Cp1252"));
Object object_root = input.read();
String object_root_str = object_root.toString();
String[] array = object_root_str.split(".,");
ArrayList<String> arrayString = new ArrayList<String>(Arrays.asList(array));
and then
ArrayList<StringBuffer> arraySB = (ArrayList<StringBuffer>)arrayS;
but it says it can't be converted
I need to know if there's a way to save my ArrayList<StringBuffer>
using BufferedWriter (because i need it to be CP1252) as an object or an ArrayList<StringBuffer>
. Or I need to find a way to get my saved String to be a ArrayList<StringBuffer>
again