黑马程序员技术交流社区
标题:
执行完以后没内容了,为什么?
[打印本页]
作者:
abc张强8
时间:
2014-7-2 22:10
标题:
执行完以后没内容了,为什么?
[code]import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Scanner;
public class DeleteKeyX {
/**
* @param args
* @throws FileNotFoundException
*/
public static void main(String[] args) throws FileNotFoundException {
if(args.length!=2){
System.out.println("Usage:java DeleteKeyX keyX fileName");
System.exit(0);
}
File fileName=new File(args[1]);
if(!fileName.exists()){
System.out.println("file"+args[1]+"does not exist");
System.exit(0);
}
Scanner input=new Scanner(fileName);
PrintWriter output=new PrintWriter(fileName);
while(input.hasNext()){
String s=input.nextLine();
String s1=s.replaceAll(args[0], "");
output.println(s1);
}
input.close();
output.close();
}
// TODO Auto-generated method stub
复制代码
[/code]
作者:
马到成功2014
时间:
2014-7-2 22:28
你先在最上面输出args[0],就知道了
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2