How read/write to text file from array?
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   david_huang
Posted On:   Sunday, May 12, 2002 11:41 PM

I try to write text file from array. Here the code: try { FileWriter fw= new FileWriter("customer.txt"); PrintWriter pw = new PrintWriter(fw); for(int i=0;i { pw.println(cp[i].writeObject()); } pw.close(); } catch( IOException ioException ) { System.out.println("An error occur while write the text file."); } JOptionPane.showMessageDialog(null," Succesfully Write the File",shopName,JOptionPane.INFORMATION_MESSAGE); Note:(above code) cp[0]= new Customer("dad",22) cp[1]= new CashCustomer("daaa"   More>>

			I try to write text file from array.
			

Here the code:



try

{

FileWriter fw= new FileWriter("customer.txt");


PrintWriter pw = new PrintWriter(fw);


for(int i=0;i


{


pw.println(cp[i].writeObject());


}


pw.close();


}



catch( IOException ioException )


{


System.out.println("An error occur while write the text file.");


}


JOptionPane.showMessageDialog(null," Succesfully Write the File",shopName,JOptionPane.INFORMATION_MESSAGE);



Note:(above code)


cp[0]= new Customer("dad",22)


cp[1]= new CashCustomer("daaa",333,"Cash")



The Question is:


How can i read the text file and copy the text file to the Array ? (cp[i])



Thank You for your help

   <<Less
About | Sitemap | Contact