MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / createTempFile

Method createTempFile

vm/JavaAPI/src/java/io/File.java:295–316  ·  view source on GitHub ↗
(String prefix, String suffix, File directory)

Source from the content-addressed store, hash-verified

293 }
294
295 public static File createTempFile(String prefix, String suffix, File directory) throws IOException {
296 if (prefix.length() < 3)
297 throw new IllegalArgumentException("Prefix string too short");
298 if (suffix == null)
299 suffix = ".tmp";
300 if (directory == null) {
301 String tmpDir = System.getProperty("java.io.tmpdir");
302 if (tmpDir == null) tmpDir = "/tmp";
303 directory = new File(tmpDir);
304 }
305
306 File f;
307 do {
308 long n = System.currentTimeMillis();
309 f = new File(directory, prefix + n + suffix);
310 } while (f.exists());
311
312 if (!f.createNewFile())
313 throw new IOException("Unable to create temporary file");
314
315 return f;
316 }
317
318 public static File createTempFile(String prefix, String suffix) throws IOException {
319 return createTempFile(prefix, suffix, null);

Callers 15

runTestMethod · 0.95
copyToTempMethod · 0.95
BackgroundMediaMethod · 0.95
createMediaMethod · 0.95
captureAudioMethod · 0.95
openMethod · 0.95
initMethod · 0.95
runMethod · 0.95
createMediaAsyncMethod · 0.95

Calls 5

getPropertyMethod · 0.95
currentTimeMillisMethod · 0.95
existsMethod · 0.95
createNewFileMethod · 0.95
lengthMethod · 0.65

Tested by 15

runTestMethod · 0.76
setUpMethod · 0.76
loadCssMethod · 0.76
encodeDecodeRoundTripMethod · 0.76
parseResourceFileXmlMethod · 0.76
runWorkerBundleMethod · 0.36