Skip to content

Commit

Permalink
tempFile +simple
Browse files Browse the repository at this point in the history
  • Loading branch information
phlppchrtn committed Jun 4, 2024
1 parent b0d2954 commit cfb1634
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions vertigo-core/src/main/java/io/vertigo/core/lang/TempFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,26 +43,28 @@ public final class TempFile {
}

/**
* Crée un fichier temporaire.
* @param prefix Prefix du nom de fichier
* @param suffix Suffix du nom de fichier
* @param subDirectory Sous-répertoire des fichiers temporaires (null = répertoire temporaire de vertigo = ${java.io.tmpdir}/vertigo/tempFiles)
* @throws IOException Exception IO
*/
* Crée un fichier temporaire.
* @param prefix Prefix du nom de fichier
* @param suffix Suffix du nom de fichier
* @param subDirectory Sous-répertoire des fichiers temporaires (null = répertoire temporaire de vertigo = ${java.io.tmpdir}/vertigo/tempFiles)
* @throws IOException Exception IO
*/
public static File of(final String prefix, final String suffix, final String subDirectory) throws IOException {
final File file = new File(Files.createTempFile(Files.createDirectories(VERTIGO_TMP_DIR_PATH.resolve(subDirectory)), prefix, suffix).toAbsolutePath().toString());
file.deleteOnExit();
return file;
return of(prefix, suffix, Files.createDirectories(VERTIGO_TMP_DIR_PATH.resolve(subDirectory)));
}

/**
* Crée un fichier temporaire.
* @param prefix Prefix du nom de fichier
* @param suffix Suffix du nom de fichier
* @throws IOException Exception IO
*/
* Crée un fichier temporaire.
* @param prefix Prefix du nom de fichier
* @param suffix Suffix du nom de fichier
* @throws IOException Exception IO
*/
public static File of(final String prefix, final String suffix) throws IOException {
final File file = new File(Files.createTempFile(Files.createDirectories(VERTIGO_TMP_DIR_PATH), prefix, suffix).toAbsolutePath().toString());
return of(prefix, suffix, Files.createDirectories(VERTIGO_TMP_DIR_PATH));
}

private static File of(final String prefix, final String suffix, final Path path) throws IOException {
final File file = new File(Files.createTempFile(path, prefix, suffix).toAbsolutePath().toString());
file.deleteOnExit();
return file;
}
Expand Down

0 comments on commit cfb1634

Please sign in to comment.