All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ws.schild.jave.utils.AutoRemoveableFile Maven / Gradle / Ivy

Go to download

The JAVE (Java Audio Video Encoder) library is Java wrapper on the ffmpeg project. Developers can take take advantage of JAVE2 to transcode audio and video files from a format to another. In example you can transcode an AVI file to a MPEG one, you can change a DivX video stream into a (youtube like) Flash FLV one, you can convert a WAV audio file to a MP3 or a Ogg Vorbis one, you can separate and transcode audio and video tracks, you can resize videos, changing their sizes and proportions and so on. Many other formats, containers and operations are supported by JAVE2.

There is a newer version: 3.5.0
Show newest version
package ws.schild.jave.utils;

import java.io.File;
import java.util.Arrays;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Use this class in a try-with-resources block to automatically delete the referenced file when
 * this goes out of scope.
 *
 * @author mressler
 */
public class AutoRemoveableFile extends File implements AutoCloseable {

  private static Logger logger = LoggerFactory.getLogger(AutoRemoveableFile.class);

  private static final long serialVersionUID = 1270202558229293283L;

  public AutoRemoveableFile(File parent, String child) {
    super(parent, child);
  }

  @Override
  public void close() {
    boolean closed = delete();
    if (!closed) {
      logger.warn(
          "File "
              + getAbsolutePath()
              + " did not automatically delete itself: "
              + Arrays.toString(Thread.currentThread().getStackTrace()));
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy