Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple file processing

Status
Not open for further replies.

sroberts82

Programmer
Oct 11, 2005
36
US
Hi I was wondering if someone could help me. I have a directory with a number of .log files. I want to be able to pass the name of the directory in as a command line arguement, and process each of the *.log files and output the results into 1 single file. How can I go about this? Thank you in advance,
Ste
 
Create a java.io.File object using the String arg of the directory.

Open a fileoutputstream or filewriter object for your output file.

Use the listFiles() method on that object to get a list of files, using a custome FilenameFiler object to filter out the ".log" files.

For each file in the list, open the file, read the contents, and write out to your output file, then close.

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top