Unknown characters before String filename list in android application

Tags: , ,



I’ve saved an array list in the android mobile storage with a .txt extension. The problem is that there are unknown characters (as it’s shown in the screenshot) coming before each file name that my string does not contain these characters.

  if (uri != null)
                file = resolver.openFileDescriptor(uri, "w");

            if (file != null) {
                FileOutputStream fileOutputStream = null;
                fileOutputStream = new FileOutputStream(
                        file.getFileDescriptor());

                ObjectOutputStream out = new ObjectOutputStream(fileOutputStream);
                for (int i = 0; i < myList.size(); i++) {

                    out.writeObject(removeAccents(myList.get(i).getName() +"n"));
                }


//                out.flush();
                out.close();

                fileOutputStream.close();
                file.close();

and the screenshot is: screenshot

Answer

Instead of using ObjectOutputStream, I should use OutputStreamWriter.



Source: stackoverflow