Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Read Multiple (not all) files from a directory and write in to another dir

715138Feb 2 2012 — edited Feb 7 2012
I have a requirement in which I have a directory where more than 500 files are present with the same extension.I have to read around 10 files from the directory based on some file name and then write it them separately in some another directory.The file names which I have to read are stored in an environment variable .

The file names are like dcp_am.txt ,dct_pain.txt ,slt_rt_00_q.txt ect

I have taken them in a single String [] fileName={"dcp_am.txt ,dct_pain.txt ,slt_rt_00_q.txt "} but do not know how to move ahead from here.I have heard about "listFiles" .

Through list files I can do File[] files = dir.listFiles();
and then in a loop I can get the files.getName();

but how I will match the required file name with all the files name and then retrive them from directory (no sub directory is present ) and write them in another folder or directory.

Need help.

Edited by: user8687839 on Feb 2, 2012 5:12 AM

Edited by: user8687839 on Feb 2, 2012 5:21 AM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 6 2012
Added on Feb 2 2012
9 comments
286 views