import java.io.File;
import java.io.IOException;public class Creat {
 
public static void main(String[] args) throws IOException {
// File file= File.createTempFile("G:\\","1.txt");
  String   tempFilePath= "G:\\"; 
  File   tempDir   =   new   File(   tempFilePath   ); 
  File   temp=File.createTempFile("wwe", ".txt ",   tempDir); 
 System.out.print(temp.getAbsolutePath());
}}运行结果是在G盘下面生成一个wwe@@#@!#!@#.txt文件
为什么会有@@#@!#!@#这些啊
e@@#@!#!@#貌似是一串随机数

解决方案 »

  1.   

    还有 文档上说 File.createTempFile(String ,String)。可以这么用,但是我一直没成功 求高手指教
      

  2.   

    File   temp=File.createTempFile("wwe", ".txt ",   tempDir); 前两个参数只是生成的临时文件名称的前缀和后缀。
    在前缀之后,会跟一按照临时文件生成规则随机生成的字符串。createTempFile两个参数的方法,文件生成在临时文件夹下。
      

  3.   

    请问这是什么用法,类里创建对象吗?求解
    class Child
    {
    int no;
    Child nextChild=null;
    public Child(int no)
    {
      //给一个编号
      this.no=no;
    }
    }
      

  4.   

    楼主不妨看看这个File.createTemFile()这个函数的API,这个函数的目的在于生成临时文件,jvm关闭后就把它清空掉,当然会产生随机数,(API原话:此方法及其所有变体都不会在虚拟机的当前调用中再次返回相同的抽象路径名)。他本来就不是用来生成永久文件的,如果硬要创建到硬盘当然会出现问题。
      

  5.   

    你申请一个Child对象a a中会包含a.n
    a.Child //Child类型
    慢慢理解把