You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
84 lines
2.0 KiB
84 lines
2.0 KiB
|
|
import java.io.IOException;
|
|
import java.io.FileWriter;
|
|
import java.io.File;
|
|
import java.util.Scanner;
|
|
import java.io.FileNotFoundException;
|
|
|
|
public class Database {
|
|
|
|
public static boolean userExists(String username)
|
|
{
|
|
boolean found = false;
|
|
|
|
try {
|
|
File filex=new File("c:\\tmp\\FavoriteMovies\\files\\login_cred.txt");
|
|
Scanner scan;
|
|
scan = new Scanner(filex);
|
|
|
|
scan.useDelimiter("[\n]");
|
|
|
|
|
|
if(scan.hasNext() && !found ) {
|
|
|
|
String line_ = scan.nextLine();
|
|
|
|
if(line_.equals(username))
|
|
found = true;
|
|
}
|
|
scan.close();
|
|
}
|
|
catch (FileNotFoundException e1) {
|
|
// TODO Auto-generated catch block
|
|
e1.printStackTrace();
|
|
}
|
|
|
|
return found;
|
|
}
|
|
|
|
public static void addMovie(Movie m){
|
|
try {
|
|
|
|
FileWriter fw = new FileWriter( "C:\\Users\\skc\\eclipse-workspace\\first\\Favorite_Movies\\src\\files\\data.txt",true);
|
|
fw.write(m.getMovieId());
|
|
|
|
fw.append(" ").write(m.getTitle());
|
|
|
|
fw.append(" ").write(m.getYear());
|
|
|
|
fw.append(" ").write(m.getLength());
|
|
|
|
fw.append(" ").write(m.getGenre());
|
|
|
|
fw.append(" ").write(m.getStudioName());
|
|
|
|
fw.append(" ").write(m.getProducerName());
|
|
|
|
fw.append(" ").write(m.getShortDescription());
|
|
|
|
fw.append(" ").write(String.valueOf(m.getAvgRating()));
|
|
|
|
fw.append(" ").write(m.getNumWatched());
|
|
|
|
fw.write("\n");
|
|
|
|
fw.close();
|
|
|
|
}
|
|
catch (IOException e1) { // TODO Auto-generated catch block
|
|
e1.printStackTrace();
|
|
}
|
|
|
|
}
|
|
|
|
public static void addStar(Star s)
|
|
{
|
|
|
|
}
|
|
|
|
public static void addRating(Rating r)
|
|
{
|
|
|
|
}
|
|
|
|
}
|