• Post Reply Bookmark Topic Watch Topic
  • New Topic

file handling problem  RSS feed

 
Anandh Ramesh
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

i have to write a code that gets the filename from a list, finds out which directory the file is in, search the file if the words 'read', 'write', 'open', 'close' etc are available in the file, and retrieve certain parameters that occur in the corresponding statements, and put those parameters in a separate file.

i am totally stuck with the problem...

can someone help me out?



-Anandh
 
Joe Ess
Bartender
Posts: 9406
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Java Tutorial is always a good starting place. The chapter on Input/Output will give you the basics on how to work with files. You should also become familiar with the Java API Documentation. There you can get all the details on every class ni the Java API. For example, java.io.File is the class which represents the native file system. It has methods to find the root direcories, list sub directories and so on and may be useful when writing a program which would search a file system. . .
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You listed of a bunch of little problems: get, find, search, retrieve, put. I'd suggest you solve them one at a time. Compared to trying to write the whole thing in one huge chunk, that approach gives you regular little doses of success and actually causes your code to be better organized.

Think about writing two things at once: the code you'll hand in at the end, and another program that tests little parts of the real one. For example, the test for the first part might look like this:

All this has to do is read a file into an array. The javadoc and a quick google for "java read file" will get you there in a jiffy.

Keep us posted on how this goes! If you try something and it doesn't work, post some code. Cheers!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!