Hola! Soy nuevo en Java y estoy haciendo un programa en el que en un JFrame te pide cargar un vídeo, quiero que salga una interfaz en la que buscar el vídeo y posteriormente ese mismo vídeo en formato mp4 sea copiado a un directorio establecido de forma predeterminada, gracias!
Uso Eclipse
Para seleccionar el fichero usa JFileChooser, para copiar el fichero a otra carpeta usa este código de http://www.java-tips.org/
// If targetLocation does not exist, it will be created.
public void copyDirectory(File sourceLocation , File targetLocation)
throws IOException {
if (sourceLocation.isDirectory()) {
if (!targetLocation.exists()) {
targetLocation.mkdir();
}
String[] children = sourceLocation.list();
for (int i=0; i<children.length; i++) {
copyDirectory(new File(sourceLocation, children[i]),
new File(targetLocation, children[i]));
}
} else {
InputStream in = new FileInputStream(sourceLocation);
OutputStream out = new FileOutputStream(targetLocation);
// Copy the bits from instream to outstream
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
in.close();
out.close();
}
}