生成文件的问题

xinshou1979330 2006-06-08 10:22:13
String writeEnc = "SJIS";
String path = "f:\\creat.xml" ;
BufferedWriter file = new BufferedWriter( new OutputStreamWriter( new FileOutputStream( path ),writeEnc ) );

为什么我这样写提示:
访问被拒绝了。
这个错误呢?
我想在指定盘符生成一个文件
谢谢了
...全文
169 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
kingofworl 2006-06-08
  • 打赏
  • 举报
回复
这段代码没有问题 ,是不是其它问题,比如f盘没格式化

try
{
String writeEnc = "SJIS";
String path = "c:\\creat.xml" ;
BufferedWriter file = new BufferedWriter( new OutputStreamWriter( new FileOutputStream( path ),writeEnc ) );

}catch(Exception e){}
安迪 2006-06-08
  • 打赏
  • 举报
回复
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;

public class test_call {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String writeEnc = "SJIS.txt";
String path = "E:/";
File aFile = new File(path, writeEnc);
FileOutputStream outputFile = null;
try {
outputFile = new FileOutputStream(aFile, true);
} catch (FileNotFoundException e) {
e.printStackTrace(System.err);
System.exit(1);
}
}
}

62,615

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧