Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Layout implements Serializable {
- private String username;
- private String password;
- public String getUsername() {
- return username;
- }
- public void setUsername(String username) {
- this.username = username;
- }
- public String getPassword() {
- return password;
- }
- public void setPassword(String password) {
- this.password = password;
- }
- public Layout(){
- username="";
- password="";
- }
- public Layout(String user,String pass){
- username=user;
- password=pass;
- }
- @Override
- public String toString() {
- return "Match Found! [Username: " + username + ", Password: " + password+"]";
- }
- int i;
- Layout[] items = new Layout[1];
- CrunchifySerializeDeserialize c = new CrunchifySerializeDeserialize();
- for (i = 0; i < items.length; i++) {
- items[i] = c.new Layout();
- }
- String a = JOptionPane.showInputDialog("Enter Username");
- String b = JOptionPane.showInputDialog("Enter Password");
- items[0].setUsername(a);
- items[0].setPassword(b);
- System.out.println("Personal info Details.....");
- for (Layout d : items) {
- System.out.print(d.getUsername());
- System.out.print("t" + d.getPassword());
- }
- List<Layout> obj;
- obj = new ArrayList<Layout>();
- for (i = 0; i < items.length; i++) {
- obj.add(items[i]);
- }
- items=new Layout[1];
- try {
- ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("./Test1.txt",true));
- out.writeObject(obj);
- out.close();
- System.out.println("nSerialization Successful... Checkout your specified output file..n");
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- try {
- //FileInputStream fileIn = new FileInputStream("./Crunchify_Test1.txt");
- ObjectInputStream in = new ObjectInputStream(new FileInputStream("./Test1.txt"));
- boolean check = true;
- while(check){
- try{
- System.out.println("Deserialized Data: n" + in.readObject().toString());
- //reinitailize shit
- }catch(EOFException e){
- check=false;
- }
- }
- //System.out.println("Deserialized Data: n" + in.readObject().toString());
- in.close();
- //fileIn.close();
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement