当前位置: 代码迷 >> Java相关 >> [求助]怎么样修改
  详细解决方案

[求助]怎么样修改

热度:304   发布时间:2006-01-05 20:13:00.0
[求助]怎么样修改
import java.io.*;
public class IOStreamDemo2 {
public static void main (String args[]) {
int b;
try {
BufferedInputStream in =
new BufferedInputStream(
new FileInputStream("input.txt"));
FileOutputStream out =
new FileOutputStream("output.txt",true);
while ((b=in.read()) !=-1)
out.write(b);
in.close();
out.close();
}catch(FileNotFoundException e) {
System.out.println("File Not Found.");
}catch (IOException e) {
System.out.println("IO Exception");
}finally { }
}
}
如果我要把input文件复制到别的地方要怎么修改?
谢谢帮忙!
----------------解决方案--------------------------------------------------------
你的意思是把input.txt移动到别的目录,
运行这个程序还能正常调用input.txt文件吗!
那只有丛命令行参数args下手了.
----------------解决方案--------------------------------------------------------

那假如我要实现这个功能该怎么写?我不会,能给个具体的不?


----------------解决方案--------------------------------------------------------
你在用Dos编译这个Java文件的时候的那个:
javac C:\javafile\xxx.java
就是了。
args=="C:\javafile\xxx.java"
就这样(好象是这样)

----------------解决方案--------------------------------------------------------

如你的程序名是TT,就这样得到路径:
(在Dos中)
TT C:\xxxxx...
那么这个args=="C:\xxxx...."


----------------解决方案--------------------------------------------------------
谢谢你啊
----------------解决方案--------------------------------------------------------
import java.io.*;
public class IOStreamDemo2 {
public static void main (String args[]) {
int b;
try {
BufferedInputStream in =
new BufferedInputStream(
new FileInputStream("input.txt"));
FileOutputStream out =
new FileOutputStream("D:\\output.txt",true);
while ((b=in.read()) !=-1)
out.write(b);
in.close();
out.close();
}catch(FileNotFoundException e) {
System.out.println("File Not Found.");
}catch (IOException e) {
System.out.println("IO Exception");
}finally { }
}
}
----------------解决方案--------------------------------------------------------
  相关解决方案