Citation :
 
 
 Source source = new DOMSource(devisToDocument(documentBuilder, numeroDevis, dateCreation, sForm, contexte));
         //Création du fichier XML à partir de l'arbre DOM
         String name_fic="c temp" + File.separator + "aa_" + numero + ".xml";
         FileOutputStream fileOutputStream = new FileOutputStream(name_fic);
         Result result = new StreamResult(fileOutputStream);
         transformer.transform(source, result);
         fileOutputStream.close();
                URL url = new URL("http://repCible/sous" );
      URLConnection connection = url.openConnection();
      connection.setDoOutput(true);
      connection.setDoInput(true);
      connection.setDoInput(true);
      connection.setUseCaches(false);
          // set some request headers
      connection.setRequestProperty("Connection", "Keep-Alive" );
      connection.setRequestProperty("Cache-Control", "no-cache" );
      connection.setRequestProperty("HTTP_REFERER",
                               "http://pluton/recette" );
      connection.setRequestProperty("Content-Type",
                               "multipart/form-data; charset=utf-8;boundary=****4353" );
      
      DataOutputStream dstream = new	DataOutputStream(connection.getOutputStream());
       dstream.writeBytes("--****4353\r\n" );
          dstream.writeBytes("Content-Disposition: form-data; name=\"uploadedFile\"; filename=\"" +
            name_fic+ "\"\r\nContent-Type: application/octet-stream\r\n\r\n" );
       //write file content
         FileInputStream fi = new FileInputStream(name_fic);
         byte[] bt = new byte[102400];
         int cnt = fi.read(bt);
         int numOfByteSent = cnt;
         while (cnt == bt.length) {
             dstream.write(bt, 0, cnt);
             dstream.flush();
             cnt = fi.read(bt);
             numOfByteSent += cnt;
         }
         dstream.writeBytes("\r\n--****4353--\r\n\r\n" );
         dstream.flush();
         dstream.close();
         fi.close();
         // end write file content
                   try {
             DataInputStream in =
                     new DataInputStream(connection.getInputStream());
             String sIn;
             while ((sIn = in.readLine()) != null) {
                 if (sIn != null) {
                     System.out.println(sIn);
                 }
                 if (sIn.equals("upload success" )) {
                    
                 }
             }
            
         } catch (Exception ex) {
             ex.printStackTrace();
         }
 
   |