Created
November 17, 2014 09:34
-
-
Save yassaa/8c47f8e491714e4b69f8 to your computer and use it in GitHub Desktop.
bl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package test_Bookingsystem; | |
import java.io.DataInputStream; | |
import java.io.DataOutputStream; | |
import java.io.FileInputStream; | |
import java.io.FileOutputStream; | |
import java.io.IOException; | |
public class UserDatabase { | |
//write to file | |
// GetUsers takes no parameter; it reads all the users from the database | |
public void saveUser(User user) { | |
try(DataOutputStream output = new DataOutputStream(new FileOutputStream("UserDatabase1.dat"))){ | |
} | |
//adding catch blocks | |
catch (IOException ex) { | |
System.out.println(" .... "); | |
} | |
} | |
public void User[] getUsers ( ){ | |
//DataInputStream reads bytes from the stream and converts them into | |
//appropriate primitive-type values or strings. | |
try(DataInputStream input = new DataInputStream(new FileInputStream("UserDatabase1.dat"))){ | |
System.out.println("User Name: " + input.readUTF()); | |
System.out.println("Email: " + input.readUTF()); | |
System.out.println("Phonenumber: " + input.readLong()); | |
} | |
//adding catch blocks | |
catch (IOException ex) { | |
System.out.println("...."); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment