File myFile=File.createTempFile("abcde",".txt",fi);

解决方案 »

  1.   

    RandomAccessFile好像只能对已有的文件操作
    建议你使用DataOutputStream类
      

  2.   

    为什么创建出来的文件,名字是"abcde5460.txt"??
      

  3.   

    import java.io.*;public class try1
    { public static void main(String[] args){

    File theFile = new File("D:/sample/abcde.txt");
    if (!theFile.exists()){
    try{
    theFile.createNewFile();

    //FileOutputStream ranFile=new FileOutputStream(theFile);
    //ranFile.write("lalalala");
    //ranFile.close();
    RandomAccessFile ranFile=new RandomAccessFile(theFile,"rw");
    ranFile.writeChars("lalalala");
    }catch(IOException e){}
    }
    }
    }createTempFile()创建出来的文档,有一些随机产生的数值