8
8
8_JOHN_82019-02-02 11:45:54
Java
8_JOHN_8, 2019-02-02 11:45:54

Why is the serialized file not being created?

final HashMapDirectory hashMapDirectory = new HashMapDirectory();
private String serializfileName = "hashmap.ser";

        encrypt_btn.setOnClickListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View v)
            {
                try
                {
                    ObjectOutputStream output = new ObjectOutputStream(new FileOutputStream(serializfileName, true));   // <------------------?????
                    hashMapDirectory.Test(edit_login.getText().toString(), edit_pass.getText().toString());
                    output.writeObject(hashMapDirectory.map);
                    output.close(); 
                    Message("Save");
                }
                catch (Throwable throwable)
                {
                    throwable.printStackTrace();
                    Message("ERROR");
                }
            }
        });

Hello, the crux of the matter is, I want to store a class object in a serialized file, the class itself
does implements Serializable. The problem is that the "hashmap.ser" file itself is not created (I marked with an arrow where this part in which I throw the "FileNotFoundException" error) as I understand it, this error says that the file was not found, but the FileOutputStream first checks for such file or not, if not, creates, and if yes, then with the parameter true, it will append to the file. I looked at a lot of examples on Google and YouTube, no matter how I tried the same thing, maybe I declared something in the wrong place somewhere? Please write what is the problem.
PS This is a phone app.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question