Question

enter code hereI am trying to specify a directory for a txt.file which is being created when the jar file is run, is there anyway to specify as an argument in the console the directory of where i want that txt file to be created:

Below is the main arguments:

 public static void main(String[] args) {
    // TODO Auto-generated method stub C:\Users\802591720\Documents\mystuff\Programs\JavaCode\xmlSchema\ManageBillingCreditAndDebit.20130219.xsd
    //String fileName = "ManageBillingCreditAndDebit.20130219.xsd";
    //String Source = "C:\Users\607817544\as1\";
    String path1 = args[0];
    String FileName = args[1];
    TagDef tagDef;
String[] operations;
try {
    operations = listOperationsUnique("C:\\Users\\607817544\\as1\\ManageBillingCreditAndDebit.20130219.wsdl");
    System.out.println("operation:" + operations.length);
    for (int i = 0; i < operations.length; i++) {
        System.out.println("operation:" + operations[i]);
    }
} catch (FileNotFoundException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
} catch (SAXException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
} catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
} catch (ParserConfigurationException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}

try {
    tagDef = refheader(path1, FileName); 

    System.out.println("=================================================================");
    System.out.println("Tag details");
    System.out.println(tagDef);
    System.out.println("=================================================================");

} catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();

}

} }

And this is the writing of the file:

System.out.println("");
                 fh.openFile("hello.txt");
                 fh.writeLine("");
                 fh.closeFile();

How do i go about specifying where I want to that file to be created in the command console? Last piece for my Java Application so any pointer would be great guys!

Any help guys is amazing, its such a minor issue I cant seem to get around

Was it helpful?

Solution

I would suggest you to use Swing text field to open up when you click on jar, and after entering the path in the text field, give submit action which should take the data from text field and do your further logic.

so giving UI like this to enter path is actually good way..

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top