简体   繁体   English

如何从文件中临时读取?

[英]How to read from file in temp?

i have problem, how to read file in temp and get filename ? 我有问题,如何在temp中读取文件并获取文件名?

  tempFile = File.createTempFile("MyFile.txt", ".tmp" );
  System.out.print("Created temporary file with name ");
  System.out.println(tempFile.getAbsolutePath());
  1. Reading a file in a temporary directory is done in exactly the same way as non-temporary files are read. 读取临时目录中的文件的方式与读取非临时文件的方式完全相同。

  2. getAbsolutePath() returns the absolute path name of the file. getAbsolutePath()返回文件的绝对路径名。 If by "file name" you refer to just the "file" portion of the path name, use the getName() method. 如果通过“文件名”仅引用路径名的“文件”部分,请使用getName()方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM