Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Writing/Reading to a file as a sting
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
bozi39




PostPosted: Tue Oct 10, 2006 10:57 am   Post subject: Writing/Reading to a file as a sting

Hey Guys. My comp sci teacher gave us this new assignment where we r supposed to use java to make 2 programs, one of which will receive the input information and write it to a file, and the other of which will open the file created by the previous and display its contents. Since the assignment requires numerous data entries, i thaught of making it so that the info being entered gets stored in the file as an array(since the file is not .txt) and the other program will open the created file and read the contents of the array as 1 whole rather than as separate entries. Do any of u have an idea as to how the syntax for these 2 programs will look?Like where would i position the writing statements and how would i make sure the reading program reads the array as 1 whole thing rather than as separate elements.
Thanks in advance
Sponsor
Sponsor
Sponsor
sponsor
HellblazerX




PostPosted: Tue Oct 10, 2006 1:16 pm   Post subject: (No subject)

What you're asking can't be done, or at least I don't think it can be done. Arrays are a way of organizing variables, they're not a form of storage, so you can't simply write an array onto a file. You'll have to store the array as separate entries. As for reading and writing from a file, you'll need the BufferedReader and BufferedWriter classes, so consult the Java API or the Java Almanac for it.
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: