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

创建临时文件

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

439
创建一个临时文件

import java.io.BufferedWriter;

import java.io.File;

import java.io.FileWriter;
/*
nowjava.com - 时  代  Java
*/

import java.io.IOException;


public class Main {

  public static void main(String[] argv) {

    try {

      // Create temp file.

      File temp = File.createTempFile("pattern", ".suffix");


      // Delete temp file when program exits.
      /* 
       来自 
      *n o w  j a v a  . c o m*/

      temp.deleteOnExit();


      // Write to temp file

      BufferedWriter out = new BufferedWriter(
展开阅读全文