Browse Source

Implements helper function for serialization

feature-serializer
fdai5728 3 years ago
parent
commit
904e9de7b0
  1. 23
      src/main/java/CredentialRepository.java

23
src/main/java/CredentialRepository.java

@ -1,3 +1,7 @@
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.util.ArrayList; import java.util.ArrayList;
/** /**
@ -128,6 +132,25 @@ public class CredentialRepository implements CredentialRepositoryInterface{
} }
/**
* Function for serialization of all Credentials
* @param fileName
*/
public void serializeObject(String fileName)
{
if(fileName.equals("")) return;
try {
FileOutputStream file = new FileOutputStream(this.getWorkingDirectory() + fileName + ".claud11");
ObjectOutputStream out = new ObjectOutputStream(file);
out.writeObject(this.credentials);
} catch (Exception fail) {
System.err.println("Serialization failed!");
}
}
/** /**
* helper function to check list size after insertion / deletion * helper function to check list size after insertion / deletion
* @return * @return

Loading…
Cancel
Save