小弟在写一个文件过滤的程序,基于结构化的比较。现在有一个Parser可以重用,在Readme中发现使用方法。
用command prompt编译完之后,执行命令如下
Java + Parser名字(也就是编译文件的名字) + 文件的绝对路径 可以把文件内容按照自己的设计过滤成另外一个文件。但是,我现在想稍微改变一下这个Java命令。我设计的是 Java + Parser名字(编译文件的名字) + 文件的绝对路径1 + 文件的绝对路径2,这样,一下子就能过滤两个文件。我想请问大家,上述方法如何实现?
用command prompt编译完之后,执行命令如下
Java + Parser名字(也就是编译文件的名字) + 文件的绝对路径 可以把文件内容按照自己的设计过滤成另外一个文件。但是,我现在想稍微改变一下这个Java命令。我设计的是 Java + Parser名字(编译文件的名字) + 文件的绝对路径1 + 文件的绝对路径2,这样,一下子就能过滤两个文件。我想请问大家,上述方法如何实现?
解决方案 »
- 帮忙写个socket客户端代码,要求能连接到Socks5代理服务器,服务器有用户名密码验证。
- 关于 GUI 报表问题,是用什么第三方控件好
- 再问hashCode()
- 新人提个简单的问题 在线等。。。。。
- ■■请教eclipse中使用VE插件可以图形化显示,可是直接代码复制生成的类却不能可视化,可以设置吗
- 请问将缓冲区中的数据输入到数组中去,该怎么实现啊?
- 网络访问的问题-有高手么!谢谢回答!
- java实现光驱自动运行,如何做?
- log4j配置文件的路径,我现在换了很多种写法,都没找到我的配置文件,请帮忙——Erazor
- 在浏览器中的Applet的源代码,放在那里了(Windows2000)。急,急急急
- 【在线等】MINA2.0 Iosession.setAttribute("name","value")疑问
- 老挝语在本地电脑乱码,做成XML文件加载到软件老挝语为乱码
for(String arg : args)
Parser.main(new String[]{arg});
}
parser类中关于main方法args的捕捉是这样的,
但是我自己试着实现了,我增加了另外一个infile和outfile用于储存另外一个文件路径的命令,但是不成功,
详细代码如下××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××public static void main(String[] args)
{
String inFile = null; /* name of the input file */
String outFile = null; /* name of the output file */
String includeDir = null;
String inFile2 = null; //
String outFile2 = null;
String includeDir2 = null;
try {
/* process the command line options */
/* there is input file */
if (args.length == 1 && !args[0].equals("-h")) {
inFile = args[0];
//inFile2 = args[0]
}
/* there are input and output files */
else if (args.length == 3 && args[0].equals("-o")) {
outFile = args[1];
// outFile2 = args[1]
// inFile = args[2];
// inFile2 = args[2];
}
/* there is an input file and an include directory */
else if (args.length == 3 && args[0].equals("-I")) {
inFile = args[2];
includeDir = args[1];
}
/* there are input and output files, and an include directory */
else if (args.length == 5 && args[0].equals("-o") && args[2].equals("-I")) {
outFile = args[1];
includeDir = args[3];
inFile = args[4];
}
/* there are input and output files, and an include directory */
else if (args.length == 5 && args[2].equals("-o") && args[0].equals("-I")) {
outFile = args[3];
includeDir = args[1];
inFile = args[4];
}
else { /* print the help message and exit */
help_print();
return;
} {
File file = new File(inFile);
File file2 = new File(inFile2);
if (!file.isFile()) {
System.err.print("Error: cannot find an input file \""
+ inFile + "\"\n");
return;
}
if (!file.canRead()) {
System.err.print("Error: cannot read an input file \""
+ inFile + "\"\n");
return;
} if(!file2.isFile()) {
System.err.print("Error: cannot find an input file2 \""
+ inFile + "\"\n");
return;
}
if(!file2.canRead())
{
System.err.print("Error: cannot read an input file2 \""
+ inFile + "\"\n");
return;
}
}
×××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××8
Parser.main(new String[]args{);这句话是干啥的?调用?
那么在另一个类里就可以这样调用:
Parser.main(new String[]{文件的绝对路径});
举个简单的例子:
T1.java
public class T1{
public static void main(String[] args) {
System.out.println(args[0].hashCode());
}
}
T2.java
public class T2 {
public static void main(String[] args) {
for(String arg :args)
T1.main(new String[]{arg});
}}
java T1 a
java T2 a b c
自己手工处理代码太混乱了。