| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 451 人关注过本帖
标题:[求助]怎么样修改
只看楼主 加入收藏
qq78141804
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2006-1-4
收藏
 问题点数:0 回复次数:6 
[求助]怎么样修改
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文件复制到别的地方要怎么修改?
谢谢帮忙!
2006-01-05 20:13
踏魔狼
Rank: 6Rank: 6
等 级:贵宾
威 望:24
帖 子:1322
专家分:33
注 册:2005-9-22
收藏
得分:0 
你的意思是把input.txt移动到别的目录,
运行这个程序还能正常调用input.txt文件吗!
那只有丛命令行参数args下手了.

=×&D o I p R e E n C g T l X&×=
2006-01-05 20:21
qq78141804
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2006-1-4
收藏
得分:0 

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

2006-01-05 20:42
踏魔狼
Rank: 6Rank: 6
等 级:贵宾
威 望:24
帖 子:1322
专家分:33
注 册:2005-9-22
收藏
得分:0 
你在用Dos编译这个Java文件的时候的那个:
javac C:\javafile\xxx.java
就是了。
args=="C:\javafile\xxx.java"
就这样(好象是这样)

=×&D o I p R e E n C g T l X&×=
2006-01-05 21:03
踏魔狼
Rank: 6Rank: 6
等 级:贵宾
威 望:24
帖 子:1322
专家分:33
注 册:2005-9-22
收藏
得分:0 

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


=×&D o I p R e E n C g T l X&×=
2006-01-05 21:06
qq78141804
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2006-1-4
收藏
得分:0 
谢谢你啊
2006-01-05 21:51
l54515429
Rank: 1
等 级:新手上路
帖 子:26
专家分:0
注 册:2005-12-22
收藏
得分: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("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 { }
}
}

就算我现在什么都没有,擦掉了眼泪还是抬头要挺胸,面带笑容不气馁往前冲。 我越挫越勇,我永远不退缩。
2006-01-05 22:56
快速回复:[求助]怎么样修改
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015870 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved