集册 Java实例教程 创建临时文件

创建临时文件

欢马劈雪     最近更新时间:2020-01-02 10:19:05

444
创建临时文件

 /*N o w J a v a . c o m*/

import java.io.*;

 

public class Main {

 

  public static void main(String[] args) {

    File file1 = null;

    File file2 = null;

    try {

      file1 = File.createTempFile("JavaTemp", null);

      file2 = File.createTempFile("JavaTemp", ".javatemp");

    } catch(IOException ioe) {

      System.out.println("Exception creating temporary file : " + ioe);

    }

    System.out.println("Temporary file without suffix extension: "

                             + file1.getPath());

    System
展开阅读全文