Original Post
I can't seem to load the data from phonebook.dat. I commented where the error is. Any help is great!
import java.lang.*;
import java.io.*;
import java.util.*;
class Console_Practice
{
public static void main(String args[]) throws IOException
{
Properties balance = new Properties();
// try to open phonebook.dat
FileInputStream fin = null;
try
{
fin = new FileInputStream("c:\\phonebook.dat");
}
catch (FileNotFoundException e)
{
System.out.println("Error opening file.");
}
// Load contents of phonebook.dat. ERROR: NOT WORKING HERE
try
{
while (fin != null)
{
balance.load(fin);
fin.close();
}
}
catch (IOException e)
{
System.out.println("Error reading file.");
}
// Try saving the phone book.
try
{
FileOutputStream fout = new FileOutputStream("c:\\phonebook.dat");
balance.store(fout, "Telephone Book");
fout.close();
}
catch (FileNotFoundException e) {}
}
}