如何为要传入的txt文件指定目标目录

时间:2014-04-22 11:20:06

标签: java eclipse jar executable-jar

enter code here我正在尝试为运行jar文件时创建的txt.file指定一个目录,无论如何都要在控制台中指定我想要那个txt的目录作为参数要创建的文件:

以下是主要论点:

 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();

}

} }

这是文件的写作:

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

如何指定在命令控制台中创建该文件的位置?我的Java应用程序的最后一块,所以任何指针都会很棒!

任何帮助人员都是惊人的,这是一个我似乎无法解决的小问题

1 个答案:

答案 0 :(得分:0)

我建议您在单击jar时使用Swing文本字段打开,并在输入文本字段中的路径后,提交应该从文本字段获取数据的提交操作,并执行进一步的逻辑。

所以给这样的UI输入路径实际上是好方法..