Reading a File by Knowing a part of the file name

Hi Java Gurus,
Can I copy a file to another location by knowing a part of the file name.I know the extension of the file and part of the file name.Can I copy such a file to another directory?
Eg :
0099999999_JAPPLIC_20090320.pdf is the file name.
I know the file name contains 'JAPPLIC' .Can I use this clue and the extension of the file to copy the file to another directory.
Please let me know whether it is possible or not.
Regards,
Rakesh.

Hi ,
I used the below code and I was able to solve the problem.I was able to select the files of the required extension and serach for the file names containing the text I know and use such files and move to another directory.It may be helpfulk to you people
public class FileDeletion {
public static void main (String args[]) {
     String e = "";
     String d = "C:\\TCCTouchpoints\\Attachments_Export\\outbound";
     String newFileLoc = "C:\\TCCTouchpoints\\Attachments_Export\\move";
ExtensionFilter filter = new ExtensionFilter(e);
File dir = new File(d);
File newLoc = null;
String[] list = dir.list(filter);
if (list.length == 0) return;
System.out.println("File Length "+list.length);
ArrayList fileNames = new ArrayList();
for (int i = 0; i < list.length; i++) {
/*file = new File(d + list);
boolean isdeleted = file.delete();
System.out.print(file);
System.out.println( " deleted " + isdeleted);*/
     System.out.println(list[i]);
     if(list[i].contains("_F5029.03_")){
          fileNames.add(list[i]);
          //System.out.println(list[i]);
dir = null;
for(int i=0;i<fileNames.size();i++){
     dir = new File(d+"\\"+fileNames.get(i));
     newLoc = new File(newFileLoc+"\\"+fileNames.get(i));
     if(dir.renameTo(newLoc)){
          System.out.println(dir + " is moved to "+ newLoc);
     }else {
          System.out.println("***** " dir " is not moved to "+ newLoc);
     dir = null; newLoc = null;
for(int i=0;i<list.length;i++){
     dir = new File(d+"\\"+list[i]);
     dir.delete();
class ExtensionFilter implements FilenameFilter {
private String extension;
public ExtensionFilter( String extension ) {
this.extension = extension;
public boolean accept(File dir, String name) {
return (name.endsWith(extension));
Thanks for replying .......

Similar Messages

  • When I download files, firefox is adding " .part " to the file name and the file won't open, but if i back the .part out, it opens fine.

    Firefox seems to be adding " .part " to the file names of files I downoad. Here's an example:
    YuT9iNv8.pdf.part
    I cannot open this file because it can't find an application.
    If I back out the .part, I get a box asking if I want to change the extension to .pdf I check yes, and everything works fine. It doesn't happen with other browsers (Safai).

    I get the error message saying the file could not be downloaded due because there is no enough disk space.
    How large is your HD and how much space do you have left?

  • Reading a file and changing one part of the file

    I am trying to read a file and then I want to change the first value on each line. The file I am reading is a .HEADER file. Which is just read in notepad I am just opening this like a txt file. I get no say at all how this file is created originally
    I want to change the value on the first line the a new title plus the ext .dat. The file is below. This stays the same format just with different values.
    ECG000 1 171 26112 9:14:56 23/04/2002
    ECG000 8 43(0) 8 127 79 -24066 0 AED trace
    I want to change the ECG000 to a new value eg Pat1.dat on the first line and Pat1 on the second line. When I read this file in and output to the dos window I get ECG000 0 0 0 and that is it. Any ideas why this is happening and how I can replace the values in the file??
         private void FileExt() throws IOException
              System.out.println("In function");
              BufferedReader br = new BufferedReader(new FileReader("c:\\Projects\\FirstSupport\\ECG000.HEADER"));
              String s;
              Vector data = new Vector();
              ECGFile = new FileWriter("c:\\Projects\\FirstSupport\\ECG.txt",true);
              System.out.println("Reading the file");
              while ((s = br.readLine()) != null)
              data.add(s);
              System.out.println(s);
              System.out.println("Finished");
              String label = s.substring(0, s.indexOf(" "));
              System.out.println(label);
              String newLabel = (label+".dat");
              System.out.println(newLabel);
         }

    I think this is what you're looking for:     private void FileExt() {
              java.util.List data=new ArrayList();
              String s;
              try {
                   BufferedReader br=new BufferedReader(new InputStreamReader(
                        new FileInputStream(new File("ECG000.HEADER"))));
                   while ((s = br.readLine()) != null)  {
                        data.add(s);
                        System.out.println(s);
                   br.close();
              catch (FileNotFoundException fnfe) {
                   System.out.println("Input file not found");
                   return;
              catch (IOException ioe) {
                   ioe.printStackTrace();
                   return;
              ListIterator li=data.listIterator();
              try {
                   PrintWriter ECGFile=new PrintWriter(new FileOutputStream(
                        new File("ECG.txt")));
                   while(li.hasNext()) {
                        s=(String)li.next();
                        if (s.substring(0, 6).equals("ECG000")) {
                             s="Pat1.dat"+s.substring(6, s.length());
                        ECGFile.println(s);
                   ECGFile.close();
              catch (FileNotFoundException fnfe1) {}
         }Mark

  • I have problem with Itunes losing where podcasts and some purchased music is located. Don't know how Itunes losing the locations of the files and I can't find the files on my hard drive. What can I do to stop Itunes losing location and restore my files?

    I have problem with Itunes losing where podcasts and some purchased music is located. Don't know how Itunes losing the locations of the files and I can't find the files on my hard drive. What can I do to stop Itunes losing location and restore my files?

    Try assigning Queen as the Album Artist on the compilations in iTunes on your computer.

  • I have a MacBook Pro, I want to copy Itunes files to an SD card to play in my car, the SD Card doesn't appear in Itunes when I insert it, and I don't know how to convert the files to the correct format, can anyone help?

    I have a MacBook Pro, I want to copy Itunes files to an SD card to play in my car, the SD Card doesn't appear in Itunes when I insert it, and I don't know how to convert the files to the correct format, can anyone help?
    Thank you

    So it seems from reading the COMMAND manual that my first issue is that I used a 16GB SD card, and the manual says it will only recogize up to a 2GB SD card. I did use my MB Air's SD card slot and crated a folder and dragged the music files to it, then to the card. So I am going to get a 2GB card and try that next. Otherwise just stick with the iPOD connected. At least that is 8GB

  • How to not append '.PART' to the file name of the currently downloading file, and just download the file with its normal filename

    In Windows, when Firefox (I'm currently using 7.0) downloads a file, it appends ''.PART'' to the file name of the currently downloading file and just renames it to its original file name after it finishes downloading.
    I sometimes like to watch a currently downloading video file, so it will be better if Firefox just downloads the file to its actual filename (like what Opera does), so I can easily double click the incompletely downloaded file and watch it with the video player assigned to that file extension, rather than the awkward ''Right click -> Open With -> Choose Default Program'' route with .part files.
    Does anyone know how to set Firefox to do this?

    It is possible that your anti-virus software is corrupting the downloaded files or otherwise interfering with downloading files by Firefox and prevents Firefox from renaming the .part file.
    Try to disable the real-time (live) scanning of files in your anti-virus software temporarily to see if that makes downloading work.
    See "Disable virus scanning in Firefox preferences - Windows"
    * http://kb.mozillazine.org/Unable_to_save_or_download_files

  • The printing of .pdf file from Project 2013 stops when the file name should be written. Project 2013 crashes. Does someone know what is wrong between Project 2013 and Adobe Acrobat 9?

    The printing of .pdf file from Project 2013 stops when the file name should be written. Project 2013 crashes. Does someone know what is wrong between Project 2013 and Adobe Acrobat 9?

    The Acrobat 9.x product family passed into "End of Support" mid-year of 2013.
    Acrobat 9 support of MS Project via PDFMaker stops with Office 2007.
    For Office 2013 support you must use Acrobat XI (11.0.1) or newer. 
    A good to have reference:
    https://helpx.adobe.com/acrobat/kb/compatible-web-browsers-pdfmaker-applications.html
    Acrobat Pro and Standard DC are what are currently available for purchase. 
    Be well...

  • Everytime i try and download any apps i get an error message telling me that part of the file seems to be corrupted.  How do i resolve this issue

    Everytime i try and download any apps i get an error message telling me that part of the file seems to be corrupted.  How do i resolve this issue

    Could be.
    This may be hard to believe, but I think my problem was that the built-in WiFi adapter on my HP desktop had
    gotten flaky. I switched to a Buffalo USB WiFi and the problem immediately disappeared. I never saw any errors, etc. from the Ralink adapter. Strange.  Might try another type of connection to the Internet.

  • How to repair my macbook pro when i had delete the app store file and know it telling that appstore file has been damage or incomplete and i had the version 10.6.8

    how to repair my macbook pro when i had delete the app store file and know it telling that appstore file has been damage or incomplete and i had the version 10.6.8

    so is their is any way that i can solve this matter

  • Edit copy in a CS6 file, but lock formatting of parts of the file

    I have a client that needs to be able to edit some copy in a file that I've created in adobe Illustrator CS6, but I want to be able to lock the formatting of parts of the file. I don't want them to use CS6.Suggestions?

    Can't do. At best you could offer them a hacky solution liek creating a PDF form with an editable text field, but it may end up looking awful.
    Mylenium

  • File importer detected an inconsistency in the file stucture of (file name). Reading and writing this file's metadata (XMP) has been disabled.

    I have duplicated a project to work on another computer. The project opens fine but when I import new footage/audio files I get this message. "File importer detected an inconsistency in the file stucture of (file name). Reading and writing this file's metadata (XMP) has been disabled." Then I can't play my timeline and Premier Pro crashes.  I have to force quit and restart my computer to continue working. What does this error really mean? How do you rectify?
    Our workflow requires that we duplicate projects to make updates because we are frequently revising but need to keep original project unchanged and intact.

    I have a similar issue and message , but occurs when I import AVI clips from OnLocation CS4 to Premier Pro CS4.

  • SSIS - creating part of the file name from an id in the database

    I am trying to figure out how to pull an "id" from my data source to include in the file name. Right now the file name created looks like customer_002_timestamp.txt. I need to add the id to the file name and I need to grab it at the time I get
    the data, so then the file name becomes customer_002_id_timestamp.txt.
    My data source is Oracle and I am using Attunity, so I do not have the capability of using the resultset found in the SQL Task because I have to use the data task.
    Has anyone ever extracted an id from a query against Oracle using the Attunity connector to add as part of the file name? If so, how would I add that to my control flow task?
    Thanks in advance for any assistance.

    Is it a static id value you want
    Then you can just use a SSIS variable to hold value from resultset in execute sql task
    Then inside your data flow you can use an expression for setting value of another variable which can be used for setting filename in your destination task. The expression will include logic to concatenate id variable also which we populated in the previous
    step.
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Adobe Reader XI (11.0.07) Error 2753. The File 'acrosup64.dll' is not marked for installation.

    I am getting Adobe Reader XI (11.0.07) Error 2753. The File 'acrosup64.dll' is not marked for installation when deploying from msi package. .
    Need help to resolve the issue

    Hi dingusmagii
    Can you please share the following info:
    ->  Which OS and architecture are you on
    ->  What are the exact steps being followed for installation.
    ->  Do you have any previous version of Reader already installed on your machine.
    Also it would be helpful if you can you share Windows Installer log. Please follow the steps below to create installer log
    1. Launch Notepad
    2. Copy paste the following text in notepad
    Windows Registry Editor Version 5.00
    [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Installer\]
    "Logging"="voicewarmupx"
    3. Now press Ctrl+S to save the file.
    4. In the "Filename" field type <any_file_name>.reg for e.g. abc.reg
    4. In the "Save as type" dropdown, select "All Files"
    5. Click Save button to save the file at desired location
    6. Go to the location where you saved the file and double click on it.
    7. Follow the prompts to create the registry key.
    After the registry key is added successfully, please re run the 11.0.07 patch installer. Once you get the error message click ok and then click on finish to close the installer dialog.
    Now go to C:\Users\{username}\AppData\Local\Temp and look for file with name similar to MSIxxxxx.log.
    Please upload the dump (compress the dump using WinZip or likewise) and share the link here.
    For help see link How to share a document
    regards,
    Rohit

  • I received a pdf from someone with an updated reader.  I am not able to open the file or download the update.  ERROR 1932  ????

    I received a pdf from someone with an updated reader.  I am not able to open the file or download the update.  ERROR 1932  ????

    ERROR 1935 SORRY PLEASE HELP I CANNOT OPEN ANY PDF'S ON MY COMPUTER NOW????????????????

  • I'v downloaded a tv series,paid for it, its in my itunes but with exclamation marks next to it, every time it tries to download the series it says "part of the file seems to be corrupted" and tells me to redownload it.Tried that and it comes up the same.

    I'v downloaded a tv series,paid for it, its in my itunes but with exclamation marks next to it, every time it tries to download the series it says "part of the file seems to be corrupted" and tells me to redownload it.Tried that 8 times and it comes up the same. What do I do?

    Clear the contents of ...iTunes\iTunes Media\Download and try one more time.
    If the problem recurs use the "report a problem" links in your account history and explain what has happened so far. There may be a problem with the source rather than your download of it.
    tt2

Maybe you are looking for

  • Scripting Idea for IPCU

    My company makes enterpise software to manage mobile devices. We are having a problem with iPhones because everytime iPhone Configuration Utility is updated we have to update our software to work with it. The issue is that apple does not release chan

  • Extended Rebate Agreements

    HI All Gurus, We are using the SAP ECC 5.0 Version. My Client Requires certain features which can be handled through Extended rebate agreements. As per the documentation. Can Anyone help in how to activate the Extended Rebate Agreements. Thanks in Ad

  • Did Adobe fix the "black line around PSD exported to PDF" bug?

    Just wondering. Sure it taking a LOT of extra time and space to work around this... I don't think they fixed in CS3 - so maybe in CS4? thanks, Andrew

  • Illustrator CS5 javascript JPEG export 300 DPI & max quality

    I new to Illustrator CS5 scripting (javascript) and I'm trying to export an .eps to .jpg.  With image quality 8 and DPI 300. I've seen several post asking about this (only a few with answers).  Those answer aren't working for me though. I also found

  • Mac wifi connection

    I have a new macbook air that stopped recognizing my wifi network. New router/gateway from my provider, tested in a different environment, brought a different laptop in to my home, AppleCare for over a month now. AppleCare finally told me that Engine