• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

Java File IO

Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
Java Cowboy
Posts: 16084
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure I understand exactly what you're having trouble with, but I hope this will be useful.

Look at class java.io.File. 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 ]
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic