以下实例演示了使用 File 类的 file.createTempFile() 方法在指定目录中创建文件:
import java.io.File; public class Main { public static void main(String[] args) throws Exception { File file = null ; File dir = new File( "C:/" ); file = File.createTempFile ( "JavaTemp" , ".javatemp" , dir); System.out.println(file.getPath()); } } |
以上代码运行输出结果为:
C:\JavaTemp37056.javatemp |
在线实例
字符集 & 工具
最新更新
站点信息
关注我们