String writeEnc = "SJIS"; 
String path = "f:\\creat.xml" ;
BufferedWriter file = new BufferedWriter( new OutputStreamWriter( new FileOutputStream( path ),writeEnc ) );为什么我这样写提示: 
访问被拒绝了。
这个错误呢?
我想在指定盘符生成一个文件
谢谢了

解决方案 »

  1.   

    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);
    }
    }
    }
      

  2.   

    这段代码没有问题 ,是不是其它问题,比如f盘没格式化         try
            {
                String writeEnc = "SJIS"; 
    String path = "c:\\creat.xml" ;
    BufferedWriter file = new BufferedWriter( new OutputStreamWriter( new FileOutputStream( path ),writeEnc ) );        }catch(Exception e){}