createtempfile2.java

来自「java 完全探索的随书源码」· Java 代码 · 共 33 行

JAVA
33
字号
import java.io.*;public class CreateTempFile2{  public static void main( String[] args )  {    try    {      File tempFile = File.createTempFile( "myfile" , ".tmp" );      FileOutputStream fout = new FileOutputStream(tempFile);      PrintStream out = new PrintStream(fout);      out.println("Place this test string in the temp file");      tempFile.deleteOnExit();    }    catch ( IOException ex )    {      System.out.println("There was a problem creating/writing to the temp file" );    }    System.out.println("Until you hit 'Enter' there is a temp file on the system");    try    {      System.in.read();    }    catch( IOException ex )    {      ex.printStackTrace();    }    System.exit(0);  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?