elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Recopilación Tutoriales y Manuales Hacking, Seguridad, Privacidad, Hardware, etc


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  Java
| | | |-+  Ayuda! Copiar y pegar archivos .mp4 con java
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Ayuda! Copiar y pegar archivos .mp4 con java  (Leído 1,702 veces)
OsmaK

Desconectado Desconectado

Mensajes: 1


Ver Perfil
Ayuda! Copiar y pegar archivos .mp4 con java
« en: 19 Diciembre 2015, 16:20 pm »

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


En línea

0xFer


Desconectado Desconectado

Mensajes: 400



Ver Perfil
Re: Ayuda! Copiar y pegar archivos .mp4 con java
« Respuesta #1 en: 19 Diciembre 2015, 17:55 pm »

Para seleccionar el fichero usa JFileChooser, para copiar el fichero a otra carpeta usa este código de http://www.java-tips.org/

Código
  1. // If targetLocation does not exist, it will be created.
  2. public void copyDirectory(File sourceLocation , File targetLocation)
  3. throws IOException {
  4.  
  5.     if (sourceLocation.isDirectory()) {
  6.         if (!targetLocation.exists()) {
  7.             targetLocation.mkdir();
  8.         }
  9.  
  10.         String[] children = sourceLocation.list();
  11.         for (int i=0; i<children.length; i++) {
  12.             copyDirectory(new File(sourceLocation, children[i]),
  13.                     new File(targetLocation, children[i]));
  14.         }
  15.     } else {
  16.  
  17.         InputStream in = new FileInputStream(sourceLocation);
  18.         OutputStream out = new FileOutputStream(targetLocation);
  19.  
  20.         // Copy the bits from instream to outstream
  21.         byte[] buf = new byte[1024];
  22.         int len;
  23.         while ((len = in.read(buf)) > 0) {
  24.             out.write(buf, 0, len);
  25.         }
  26.         in.close();
  27.         out.close();
  28.     }
  29. }


En línea

Código
  1. int getRandomNumber(){
  2.    return 4; //chosen by fair dice roll
  3.              //guaranteed to be random
  4. }
Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Copiar y pegar un sevicio de windows 7 ?
Windows
Whoolz 3 5,271 Último mensaje 1 Julio 2010, 03:06 am
por hitori batusai
[VB] Copiar y pegar en Visual Basic 2008
.NET (C#, VB.NET, ASP)
avmiitxe 4 9,042 Último mensaje 22 Abril 2011, 00:52 am
por Keyen Night
ayuda con bash copiar archivos
Scripting
mcricar 3 3,061 Último mensaje 19 Febrero 2013, 10:15 am
por Eleкtro
Ayuda. Copiar y pegar texto de un Richtextbox a un textbox
.NET (C#, VB.NET, ASP)
**Aincrad** 2 6,808 Último mensaje 28 Noviembre 2017, 23:58 pm
por **Aincrad**
Ayuda copiar y pegar en navegador conectado a servidor
Redes
Rachazo 0 1,718 Último mensaje 23 Diciembre 2018, 20:07 pm
por Rachazo
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines