It's not a secret anymore!
The moose likes Java in General and the fly likes Java File IO Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Java File IO" Watch "Java File IO" New topic

Java File IO

Yogendra Joshi
Ranch Hand

Joined: Apr 04, 2006
Posts: 213
Hello Ranchers ,

I have the following requirement. Would appreciate if you'll can give your best suggestions.

I want to load a path to a folder (D:\MyFolder\MyApp)using properties , i guess that i can do with Properties load method.

after loading the path D:\MyFolder\MyApp , there are 20 .db2 files , I need to dynamically append the name of the db2 file from a .csv file which is a comma seperated file to the above path. I need to get the name of the .db2 file one by one [This is where i am confused]from the csv and append it to the path i.e D:\MyFolder\MyApp\sm_sb_ac_af.db2

Once this is done , I need to byte by byte read that file and make a new file with the same name in other path which would be something like D:\MyFolder\MyApp\MyDestination\*.db2 , The new file would contain the new changes which i want.

Now the need :

The following is needed because the old .db2 file contains db2 comments i.e (--) , my java program should be able to open the old db2 file , remove all the occurances of "--" and add some custom lines like "IN" once the defination of CREATE TABLE ends.

Can someone let me know what is the best way to achieve it.

Any and all suggestions and input(s) are highly appreciated.

Thanks and Regards,
Yogendra N Joshi.

Meri Zindagi Hain Tab Tak.. Jab Tak Tera Sahara.... Har Taraf Tu Hi Tu Hain SAI Tera Hi Hain Nazara.....
Ujgar Singh Amli

Joined: Jan 11, 2006
Posts: 6
Looks like we are trying to do the same sort of thing! (Refer to my latter thread, versionwriter).

I am having problems in reading and writing to a file presentin a common file path for various projects residing in different folders relative to my class.

Did you get any further with your programme?
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15084

I'm not sure I understand exactly what you're having trouble with, but I hope this will be useful.

Look at class It contains methods to list the files in a directory. If you have a File object which represents the directory, you can call list() or listFiles() on it to get an array of File objects that represent the files (and subdirectories) in the directory. If you only want to see the files that end in ".db2", then you can pass a FilenameFilter to the listFiles() method, for example:

[ May 22, 2007: Message edited by: Jesper Young ]

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Java File IO
jQuery in Action, 3rd edition