Any one can help me?? please

I am neither strong in Java or programming!
Can understand how things work.
This is what I am trying to do:
Open a file in a directory
check if the file has xml extension.
then move the file to different directory.
The code worked if I provide the path for the FileReader. However, when I changed it to check if the given directory contains the specfic file, I got error message
Assuming there is only one xml file in a specified directory and the name of the file will be changed when it is stored in the new directory
My code:
import java.io.*;
import java.util.*;
import java.lang.String;
public class FileCopyTst1
     public static void main(String[] args) throws IOException
          File file = new File(XMLFileFilter("C:\\cluster"));
          BufferedReader fin = new BufferedReader(new FileReader(file));
          BufferedWriter fout = new BufferedWriter(new FileWriter("C:\\testCluster\\cluster1.xml"));
          String line;
          while ((line = fin.readLine()) != null)
               // Output our result to the output file
          fout.write(line);
          fout.newLine();
          // Close both files
          fin.close();
     fout.close();
     private class XMLFileFilter implements java.io.FileFilter
     public boolean accept(File f) {
     if (f.isDirectory()) return true;
     String name = f.getName().toLowerCase();
     return name.endsWith("xml");
     }//end accept
     }//end class HTMLFileFilter
}//end class
Got the following error message
C:\FileCopyTst1.java:9: cannot resolve symbol
symbol : method XMLFileFilter (java.lang.String)
location: class FileCopyTst1
          File file = new File(XMLFileFilter("C:\\cluster8"));
^
1 error
if anybody can help me thanks a lot.

Hi,
First of all you try to create object of XMLFileFilter without "new"
it's impossible and it is a reason of error you described.
Next problem: you can't create new instance of XMLFileFilter by calling
new XMLFileFilter("C:\\cluster") because you do not have such constructor.
Move XMLFileFilter outside of FileCopyTst1 because now it is inner class and it cant be instantiated without instance of outer class(FileCopyTst1)
If you want just move file you can use file.renameTo() method.
And finaly you should use file.listFiles() method for selecting XML files.
So, your code can looks like that:
import java.io.*;
import java.util.*;
import java.lang.String;
public class FileCopyTst1 {
public static void main(String[] args) throws IOException {
File file = new File("C:\\cluster");
File xmlFiles[] = file.listFiles(new XMLFileFilter());
for (int i = 0; i< xmlFiles.length;i++ ){
xmlFiles.renameTo(new File("C:\\testCluster\\cluster1.xml"));
}//end class
class XMLFileFilter implements java.io.FileFilter {
public boolean accept(File f) {
if (f.isDirectory()) return true;
String name = f.getName().toLowerCase();
return name.endsWith("xml");
}//end accept
}//end class HTMLFileFilter

Similar Messages

  • Ussd not Working on my iphone 5 Ios 7.0.3 i am form India , BSNL Carrier  Any one can Help me please . when i dail *123# then can't work its direct dailing.

    Ussd not Working on my iphone 5 Ios 7.0.3 i am form India , BSNL Carrier
    Any one can Help me please . when i dail *123# then can't work its direct dailing.

    Not ony for BSNL, Not working for all carriers in India right from 7.0 , 7.0.1, 7.0.2 and 7.0.3
    Apple needs to work it out in their  upcoming patch , All older versions of iphones from 4 and 4s works perfectly without any flaw  right from 7.0

  • My ipod is disabled and say connect to iTunes when i connect to computer it say enter the pass cod but the ipod browser it's not showing ..any one can help me please, ty

    my ipod is disabled and say connect to iTunes when i connect to computer it say enter the pass cod but the ipod browser it's not showing ..any one can help me please, ty

    Place the iPod in Recovery mode and then restore

  • My ipad is stolen ,, and i want to reopen find my ipad application because as i know once the ipad switched off and switched on again the application needs to be reopened ,, any one can help me please to find my ipad again

    my ipad is stolen ,, and i want to reopen find my ipad application because as i know once the ipad switched off and switched on again the application needs to be reopened ,, any one can help me please to find my ipad again

    Stolen
    http://support.apple.com/kb/HT5668
    Erase iPad
    http://support.apple.com/kb/ph2701
    Lost Mode
    http://support.apple.com/kb/PH2700
    Reporting lost or stolen iPad
    http://support.apple.com/kb/HT2526

  • Mc Book Air 13 won't start up. Any one can help? Please!

    Any one can help please,

    Thanks. Mc Book Air 13. Model A 1369/2011. Charger is connected. I plugged inn the charger and turned off the power button last night before I sleep. It's power on but couldn't log in/strait up. Showing only apple symbol. Thanks for your concerning.

  • I restore my iPhone 4S on iTunes and then when restarted it is asking for valid SIM card and I don't have SIM card for that, I was just using the iPhone with wifi, any one can help? Please.

    I restore my iPhone 4S on iTunes after the restore was completed the iPhone was restarted and now asking for valid SIM card which I didn't,t have and I was using the iPhone with wifi, and now can't use it because the screen is locked for SIM card. Can anyone help me please.
    Thanks,
    David

    wjosten wrote:
    Phil0124 wrote:
    I doubt the phone is locked to GCI in any way
    Well, you're wrong, & in fact not only is it locked, GCI does not offer unlocking for iPhones.
    Fact is your post won't help the OP.
    And you are 100% sure its locked to them? How can you know this? While GCI does not offer unlocking that does not mean the phone is actually locked to it. Get off your high horse.
    Its possible the original owner had an unlocked phone. he was using with GCI. Or that GCI doesn't actually have locked phones. Seeing as they don't even have their own infrastructure but instead use AT&T's I doubt they'd have iPhones specifically locked to them and that would be the reason they do not offer unlocking (because there's nothing for them to unlock). And just to clarify, I'm not saying for a fact its not locked to them. It very well maybe be, but without knowing more about the phone and going by the fact GCI uses AT&T infrastrucure its possible its not locked. But here's no way to say for sure either way.
    Trying a Sim card from AT&T or another carrier might just help the OP if its actually unlocked or locked to AT&T rather than GCI.

  • Any one can help how to install sharepoin2013 in multi servers .any deployment guide please provide

    Any one can help how to install sharepoin2013 in multi servers .if you have any  guide please provide

    I am sharing few links which can be helpful for you to understand and install/configure multi server sharepoint environment.
    Install SharePoint 2013 across multiple servers for a three-tier farm
    Test Lab Guide: Configure SharePoint Server 2013 in a three-tier farm
    Install and Configure SharePoint farm (3 -tier)
    Office Web Apps 2013 multi servers (NLB) Installation and Deployment for SharePoint
    2013 step by step guide
    Adnan Amin MCT, SharePoint Architect | If you find this post useful kindly please mark it as an answer.

  • I m trying to import some picture from my iphoto library but element 12 don't show me the iphoto dialog box , as I can see on my classroom book and in many tutorial.any one can help please

    I m trying to import some picture from my iphoto library but element 12 don't show me the iphoto dialog box ,where i choose what i want to import,  as I can see on my classroom book and in many tutorial.any one can help please ? thanks

    I have the same problem... but the photo library is neither on my iPhone or my Computer!! Please help.. its taking too much space.

  • Hi I'm a total novice, as you will see. But Iam trying to use template of an employee schedule but when I try to add extra columns it does not add the preset formula with it, so it works out total hours and total pay?   If any one can help please.

    Hi I'm a total novice, as you will see. But Iam trying to use template of an employee schedule but when I try to add extra columns it does not add the preset formula with it, so it works out total hours and total pay?   If any one can help please before I throw it through the window!

    Grum12 wrote:
    Hi I'm a total novice, as you will see. But Iam trying to use template of an employee schedule but when I try to add extra columns it does not add the preset formula with it, so it works out total hours and total pay?   If any one can help please before I throw it through the window!
    Hi Grum,
    If the formulas aren't filling to the new column, you must have changed something in the template since you first opened it. Numbers is rather fussy about filling row content in columns as they are added. Only rows with the same expression in every Body Column will fill when a column is added. Just as an experiment, start a new Employee Schedule document from the Template Chooser and then add a column by clicking the Add Column handle in the upper right corner of the table. If that works, as it should, then think about what might have changed in your working document to disconnect that feature. Maybe we can figure it out together.
    Jerry

  • Good day , please Any one can help me

    Recently I get an iPhone witch was used from many month , the problem is that I don't know the first user so I don't know the password of the existing Appel Id and I can't delete his Apple ID because i don't know it's password , I make my Owen Apple ID and I have changed many things but the problem still in the iCloud because I can't delete the existing id so all my data may go to another person so please advise 

    user12039624mhmads81 wrote:
    ... Please any one can help me to get a good document for upgrading database from Upgrade Database From 8i & 9i& 10g to 11g which include prerequisite and upgrade process and after upgrading process waiting for your response because it necessary neededI'm wondering how the previous answer is correct since it is the 10g upgrade guide whereas you're looking for a 11g upgrade.
    By the way which 11g release ?
    Once you choose your release target, got to the doc http://www.oracle.com/technology/documentation/index.html click on the link corresponding to your target version, there will be an upgrade guide with all the steps you need to know.
    Nicolas.

  • HELP. ............Hi folks hope some one can help me please.Having a problem in Bridge I open my images in ACR,  as I open files in a folder and lets say they are labeled in yellow  they are all going back to  the camera raw default , in other words no ma

    HELP. ............Hi folks hope some one can help me please.Having a problem in Bridge I open my images in ACR,  as I open files in a folder and lets say they are labeled in yellow  they are all going back to  the camera raw default , in other words no matter what work I have done, inc cropping they  all go back to ,as they came out of camera. What on earth is happening? I am on PS CS6. I might point out everything was working normally up to  yesterday, when this first started.
    I recently changed computer to 64bit from 32bit, not sure if this causing  the problem or not. Any help would be appreciated.

    Robert,
    Would you be so kind to rephrase your question with concise, precise information and without any "let's say that" hypotheticals?  Sorry, I can't quite follow you.
    Also please give exact versions of Photoshop CS6 (13.what.what), of Bridge and of your OS.
    Thanks.
    BOILERPLATE TEXT:
    If you give complete and detailed information about your setup and the issue at hand, such as your platform (Mac or Win), exact versions of your OS, of Photoshop and of Bridge, machine specs, what troubleshooting steps you have taken so far, what error message(s) you receive, if having issues opening raw files also the exact camera make and model that generated them, etc., someone may be able to help you.
    Please read this FAQ for advice on how to ask your questions correctly for quicker and better answers:
    http://forums.adobe.com/thread/419981?tstart=0
    Thanks!

  • I bought a mini DVI to HDMI convertor and  a HDMI to VGA cable to connect my mac book pro to a tv but it doesn't work any one can help.\\\\\

    i bought a mini DVI to HDMI convertor and  a HDMI to VGA cable to connect my mac book pro to a tv but it doesn't work any one can help.

    I would suggest looking into a Thunderbolt to HDMI connector. In this case, you may be able to use the TV as an external monitor. For this option, please confirm through additional research. I have not tested it personally.
    You can also use an Apple TV, which connects with HDMI. In this case, you can use Airplay Mirroring. Not all Macs support Airplay Mirroring, so you need to check first. I have a Mid-2011 27" iMac, and it supports Airplay Mirroring. I don't use it often because my TV is in another room, but I just tried it and it worked. It had to change the screen resolution to work well, so I don't know if I would want to use it as my day to day monitor. http://support.apple.com/kb/ht5404

  • Does any one can help me on Oracle cycles

    Hi Gurus,
    Does any one can help me getting documents of People to pay cycle or Recruit to retaire cycle Please.
    I am in need of them .
    Thanks in advance for your time and consideration.

    If you mean the Time Capsule's internal drive, click here and follow the instructions.
    If you mean an external drive used with Time Machine, install the MacDrive trial on the PC and then plug it in normally.
    (96092)

  • Guys!! any one can help me in recursive permutation of integer array!!

    this is the description of my problem:
    We are supposed to develop a recursive method with the following header:
    public static boolean nextPermutation(int[] array)
    The method receives an integer array parameter which is a permutation of integers 1, 2, �, n. If there is �next� permutation to the permutation represented by the array, then the method returns true and the array is changed so that it represents the �next� permutation. If there is no �next� permutation, the method returns false and does not change the array.
    Here is a verbal description of the recursive algorithm you need to implement:
    1. The first permutation is the permutation represented by the
    sequence (1, 2, �, n).
    2. The last permutation is the permutation represented by the
    sequence (n, �, 2, 1).
    3. If is an arbitrary permutation, then the �next� permutation is
    produced by the following procedure:
    (i) If the maximal element of the array (which is n) is not in the first
    position of the array, say , where , then just swap and . This
    will give you the �next� permutation in this case.
    (ii) If the maximal element of the array is in the first position, so ,
    then to find the �next� permutation to the permutation , first find
    the �next� permutation to , and then add to the end of thus
    obtained array of (n-1) elements.
    (iii) Consecutively applying this algorithm to permutations starting
    from (1, 2, �, n), you will eventually list all possible
    permutations. The last one will be (n, �, 2, 1).
    For example, below is the sequence of permutations for n = 3 , listed by the described algorithm:
    (0 1 2) ; (0 2 1) ; (2 0 1) ; (1 0 2) ; (1 2 0) ; (2 1 0)
    if any one can help me then please help me!! i am stucked at this position to find permutation of the integer array.
    thanks,

    Sure. Why don't you post the code you already have done, and maybe
    someone here can help you with it.

  • HT201263 I Have an iPhone 5 runnig ios 7.0.4. It wont start as the apple logo keeps on blinking when i connect to wall charger or itunes. I even tried to restore it but an error 21 is being displayed. Any one can help me in this situation

    I Have an iPhone 5 runnig ios 7.0.4. It wont start as the apple logo keeps on blinking when i connect to wall charger or itunes. I even tried to restore it but an error 21 is being displayed. Any one can help me in this situation

    Read http://support.apple.com/kb/ts3694#

  • Boot camp 5.0.1 aways crash when i try to create a partition for windows. My mac is new MBP retina.Any one can help me?

    boot camp 5.0.1 aways crash when i try to create a partition for windows. My mac is new MBP retina.Any one can help me?

    boot camp 5.0.1 aways crash when i try to create a partition for windows. My mac is new MBP retina.Any one can help me?

Maybe you are looking for