try (RandomAccessFile fileOnDisk = new RandomAccessFile(storage + path, "rw");
             FileChannel channel = fileOnDisk.getChannel()) {
            channel.lock(); //Exception si un autre process essaie d'y accéder
            channel.truncate(0); //Sinon le fichier n'est pas écrasé
        } catch (IOException e) {
            throw new StorageException(ERROR_SAVING_FILE, e.getMessage());
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter