| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 540 人关注过本帖
标题:代码测试
只看楼主 加入收藏
静夜思
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:济南的冬天
等 级:管理员
威 望:11
帖 子:8913
专家分:2567
注 册:2004-3-25
结帖率:100%
收藏
 问题点数:0 回复次数:3 
代码测试

import java.io.*;
public class TestFile {

public static void main(String[] args) {
int b,c;
byte[] buffer = new byte[100];
File f = new File("G:\\com.gknl");
File fTemp = null;
try {
fTemp=File.createTempFile("letter",".txt",f);
System.out.println("输入一行文本,并存入磁盘:");
b = System.in.read(buffer);
FileOutputStream writeFile = new FileOutputStream(fTemp);
writeFile.write(buffer,0,b);
FileInputStream In = new FileInputStream(fTemp);
FileOutputStream Out = new FileOutputStream("G:\\com.gknl\\line.txt");
while((c=In.read())!=-1){
Out.write(c);
}
In.close();
fTemp.deleteOnExit();
System.out.println("输入完毕!!");

} catch (IOException e1) {
e1.printStackTrace();
}



}

}


[此贴子已经被作者于2007-7-31 16:53:49编辑过]

搜索更多相关主题的帖子: 代码 
2007-07-31 16:53
静夜思
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:济南的冬天
等 级:管理员
威 望:11
帖 子:8913
专家分:2567
注 册:2004-3-25
收藏
得分:0 

[CODE]import java.io.*;
public class TestFile {
public static void main(String[] args) {
int b,c;
byte[] buffer = new byte[100];
File f = new File("G:");
File fTemp = null;

try {
fTemp=File.createTempFile("letter",".txt",f);
System.out.println("输入一行文本,并存入磁盘:");
b = System.in.read(buffer);
FileOutputStream writeFile = new FileOutputStream(fTemp);
writeFile.write(buffer,0,b);
FileInputStream In = new FileInputStream(fTemp);
FileOutputStream Out = new FileOutputStream("G:\\line.txt");
while((c=In.read())!=-1){
Out.write(c);
}
// File g = new File("G:\\line.txt");
Out.flush();
In.close();
Out.close();
System.out.println(fTemp.getAbsolutePath());
fTemp.deleteOnExit();
System.out.println("输入完毕!!");
} catch (IOException e1) {
e1.printStackTrace();
}



}
}[/CODE]


[CODE]import java.io.*;
public class TestFile {
public static void main(String[] args) {
int b,c;
byte[] buffer = new byte[100];
File f = new File("G:");
File fTemp = null;

try {
fTemp=File.createTempFile("letter",".txt",f);
System.out.println("输入一行文本,并存入磁盘:");
b = System.in.read(buffer);
FileOutputStream writeFile = new FileOutputStream(fTemp);
writeFile.write(buffer,0,b);
writeFile.close();
FileInputStream In = new FileInputStream(fTemp);
FileOutputStream Out = new FileOutputStream("G:\\line.txt");
while((c=In.read())!=-1){
Out.write(c);
}
// File g = new File("G:\\line.txt");
Out.flush();
In.close();
Out.close();
System.out.println(fTemp.getAbsolutePath());
fTemp.deleteOnExit();
System.out.println("输入完毕!!");
} catch (IOException e1) {
e1.printStackTrace();
}



}
}[/CODE]




畅所欲言
2007-07-31 16:54
静夜思
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:济南的冬天
等 级:管理员
威 望:11
帖 子:8913
专家分:2567
注 册:2004-3-25
收藏
得分:0 
System.out.println("输入一行文本,并存入磁盘:  public  324234234234");

畅所欲言
2007-07-31 17:10
静夜思
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:济南的冬天
等 级:管理员
威 望:11
帖 子:8913
专家分:2567
注 册:2004-3-25
收藏
得分:0 
回复:(静夜思)代码测试
sdfsdfsd [url]http://www.bc-cn.net[/url]

畅所欲言
2007-07-31 17:37
快速回复:代码测试
数据加载中...
 
   



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

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