2013-03-18 06:10:21 UTC
Still new to this whole programming thing, it's only been about 2 months, so I know the way I'm doing this program probably isn't't the best way, but I dont have enough time to change everything now.
Please any help would be greatly appreciated...
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;
public class Main
{
public static void main (String [] args) throws FileNotFoundException
{
String [] lName, fName, street, city, state, zip, phone;
lName = new String[20];
fName = new String[20];
street = new String[50];
city = new String[20];
state = new String[20];
zip = new String[12];
System.out.println("ADDRESS BOOK CONTENTS: ");
Scanner inFile;
try
{
inFile = new Scanner (new File("src/addresses.csv"));
String temp;
while (inFile.hasNextLine())
{
temp = inFile.nextLine();
System.out.println("Contact: " + temp);
}
System.out.println(inFile);
}
catch (FileNotFoundException e)
{
//catch block
e.printStackTrace();
}
try
{
FileInputStream fileIn = new FileInputStream("src/addresses.csv");
FileOutputStream fileOut = new FileOutputStream("src/newfile.csv");
int c;
while ((c = fileIn.read()) != -1)
{
fileOut.write(c);
}
fileIn.close();
fileOut.close();
}
catch (FileNotFoundException exception1)
{
System.err.println("FileCopy: " + exception1);
}
catch (IOException exception1)
{
System.err.println("FileCopy: " + exception1);
}
}
}