java如何为要传入的txt文件指定目标目录
enter code here
我正在尝试为txt指定一个目录。运行jar文件时正在创建的文件,是否在控制台中指定要创建该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 楼答案
我建议您在单击jar时使用Swing文本字段打开,在文本字段中输入路径后,执行submit操作,该操作将从文本字段中获取数据并执行进一步的逻辑
所以给这样的用户界面输入路径实际上是一个好方法