3

Buenas Tardes,

Tengo este código:

try{

    java.net.URL url = new java.net.URL("http://mas.lne.es/fotos/img/2007/10/62/203093470447035b9bc5a095.43783284-foto_verano.jpg);
    URLConnection urlCon = url.openConnection();
    System.out.println(urlCon.getContentType());
    InputStream is = urlCon.getInputStream()
    //FileOutputStream fos = new FileOutputStream("C:\\Users\\estudiante.cda\\Downloads\\Fuentes.zip");
    ZipOutputStream fos = new ZipOutputStream(new FileOutputStream("C:\\Users\\estudiante.cda\\Downloads\\Fuentes.zip"));

    // name the file inside the zip  file 
    fos.putNextEntry(new ZipEntry("Foto.jpg")); 
    byte[] array = new byte[4096];
    int leido = is.read(array);
    while(leido > 1){

        fos.write(array,0,leido);
        leido = is.read(array);
    }
    is.close();
    fos.close();
            }catch(Exception e){
            e.printStackTrace();
            }

     }catch(Exception e){
         e.printStackTrace();
     }

Y me sale error es decir no ejecuta! Muchas Gracias.

1
  • en la url te faltan las comillas del final el 17 abr. 2017 a las 22:16

1 respuesta 1

3

El url definido debe ser especificado como string entre comillas dobles:

java.net.URL url = new java.net.URL("http://mas.lne.es/fotos/img/2007/10/62/203093470447035b9bc5a095.43783284-foto_verano.jpg");
2
  • 1
    ps tambien el ; el 17 abr. 2017 a las 22:57
  • 1
    gracias :3 te lo agradezo :3 el 17 abr. 2017 a las 22:57

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.