Ver Mensaje Individual
  #6 (permalink)  
Antiguo 12/07/2011, 11:23
pipook
 
Fecha de Ingreso: abril-2010
Ubicación: Cartagena
Mensajes: 19
Antigüedad: 14 años, 10 meses
Puntos: 1
Respuesta: Subir archivo a servidor externo con aplicacion de escritorio

compadre muchas gracias, he resuelto la subida del archivo gracias a usted, muchas gracias, aca pongo el codigo para que vean como fue, no es mas, muchas gracias men., aunque por ultimo mira el parseo que le hize al file.length() pa poder tener el tamaño que le tengo que dar al byte[], funciono, pero no se que tal esta eso ok
Código:
            if(fold.getAllowableActions().getAllowableActions().contains(Action.CAN_CREATE_DOCUMENT)){
                JFileChooser fileChooser = new JFileChooser();
                int returnVal = fileChooser.showOpenDialog(null);
                if (returnVal == JFileChooser.APPROVE_OPTION) {
                    File file = fileChooser.getSelectedFile();
                    FileInputStream fis = null;
                    BufferedInputStream bis = null;
                    DataInputStream dis = null;
                    byte cont2[] = new byte[(int)file.length()];
                    int bites=0;
                    try {
                        fis = new FileInputStream(file);

                        // Here BufferedInputStream is added for fast reading.
                        bis = new BufferedInputStream(fis);
                        dis = new DataInputStream(bis);
                        
                        bites = dis.read(cont2);
                        // dispose all the resources after using them.
                        fis.close();
                        bis.close();
                        dis.close();

                    } catch (FileNotFoundException e) {
                        e.printStackTrace();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }

                   
                } else {
                    System.out.println("File access cancelled by user.");
                }
            }else
                JOptionPane.showMessageDialog(null,"No es posible agregar archivos en este directorio");        

    }