🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: es.comp.lenguajes.java
Article #28136

Usar metodo PUT

#28136
From: Javier Iglesias
Date: Mon, 08 Jun 1998 00:00
183 lines
10548 bytes

--------------7B14D832AFE4658630F7B08E
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit

Hola, me gustar�a saber si alguno ha usado el m�todo PUT del HTTP para
subir ficheros al servidor. Estoy realizando una aplicacioncita sobre el
tema y no consigo encontrar donde se dice que es m�todo PUT.

Os adjunto el c�digo por si os funcionara.


import java.io.*;
import java.net.*;

public class upload {
   public static void main(String[] args) {
      // Sintax:
      // java.exe upload.URLTest URLdestino Documento Proxy
      if ( (args.length < 2) && (args.length >3) ) {
        System.err.println("Uso: java.exe upload.upload URLDestino
Documento [Proxy]");
        return;
      }
      // Mostramos los par�metros
      System.err.println("Par�metros:(0,1,2)->"+ args[0]+","+
                         args[1]+","+args[2]);
      // Comenzamos las conexiones
      try {
         URL u = new URL(args[0]);
         URLConnection uc = u.openConnection();
         uc.setAllowUserInteraction(true);
         uc.setRequestProperty("Authorization", "Basic ZGVtbzpkZW1v");
         uc.setDoOutput(true);
         uc.connect();
//       BufferedReader br = new BufferedReader(
//       new InputStreamReader(uc.getInputStream()));
         BufferedWriter bw = new BufferedWriter(
            new OutputStreamWriter(uc.getOutputStream()));

         String line;
         bw.write("HOLA MUNDO EN EL SERVIDOR WEB", 0, 29);
         bw.flush();
         bw.close();

   /*      while ((line=br.readLine())!=null) {
            System.out.println("line="+line);
         }
   */
      }
      catch(Exception e) {
         e.printStackTrace();
      }
   }



Saludos, Javier.

--
______________________________________________________________
    __   __   _  __     __
   (__) |-<  /-\(__ |__(-_ Ib�rica, S.R.L.
  Javier Iglesias                 http://www.oracle.es
  Sales Consultant                Internet: figlesia@es.oracle.com
  C/ Navaluenga 1 y 3             Tfno.:    341 6312032
  Las Rozas  28230 MADRID         Fax:      341 6312128


--------------7B14D832AFE4658630F7B08E
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<HTML>
Hola, me gustar&iacute;a saber si alguno ha usado el m&eacute;todo PUT
del HTTP para subir ficheros al servidor. Estoy realizando una aplicacioncita
sobre el tema y no consigo encontrar donde se dice que es m&eacute;todo
PUT.

<P>Os adjunto el c&oacute;digo por si os funcionara.
<BR>&nbsp;

<P><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>import
java.io.*;</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>import
java.net.*;</FONT></FONT></FONT><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2></FONT></FONT></FONT>

<P><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>public
class upload {</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>&nbsp;&nbsp;
public static void main(String[] args) {</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
// Sintax:</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
// java.exe upload.URLTest URLdestino Documento Proxy</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
if ( (args.length &lt; 2) &amp;&amp; (args.length >3) ) {</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
System.err.println("Uso: java.exe upload.upload URLDestino Documento [Proxy]");</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return;</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
}</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
// Mostramos los par&aacute;metros</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
System.err.println("Par&aacute;metros:(0,1,2)->"+ args[0]+","+</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
args[1]+","+args[2]);</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
// Comenzamos las conexiones</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
try {</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
URL u = new URL(args[0]);</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
URLConnection uc = u.openConnection();</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
uc.setAllowUserInteraction(true);</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
uc.setRequestProperty("Authorization", "Basic ZGVtbzpkZW1v");</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
uc.setDoOutput(true);</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
uc.connect();</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
BufferedReader br = new BufferedReader(</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
new InputStreamReader(uc.getInputStream()));</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
BufferedWriter bw = new BufferedWriter(</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
new OutputStreamWriter(uc.getOutputStream()));</FONT></FONT></FONT><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2></FONT></FONT></FONT>

<P><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
String line;</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
bw.write("HOLA MUNDO EN EL SERVIDOR WEB", 0, 29);</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
bw.flush();</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
bw.close();</FONT></FONT></FONT><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2></FONT></FONT></FONT>

<P><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>&nbsp;&nbsp;
/*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while ((line=br.readLine())!=null) {</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
System.out.println("line="+line);</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
}</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>&nbsp;&nbsp;
*/</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
}</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
catch(Exception e) {</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
e.printStackTrace();</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
}</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>&nbsp;&nbsp;
}</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT SIZE=-2></FONT></FONT>&nbsp;
<BR>&nbsp;

<P>Saludos, Javier.

<P>--
<BR>______________________________________________________________
<BR>&nbsp;&nbsp;&nbsp; __&nbsp;&nbsp; __&nbsp;&nbsp; _&nbsp; __&nbsp;&nbsp;&nbsp;&nbsp;
__
<BR>&nbsp;&nbsp; (__) |-&lt;&nbsp; /-\(__ |__(-_ Ib&eacute;rica, S.R.L.
<BR>&nbsp; Javier Iglesias&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<A HREF="http://www.oracle.es">http://www.oracle.es</A>
<BR>&nbsp; Sales Consultant&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Internet: figlesia@es.oracle.com
<BR>&nbsp; C/ Navaluenga 1 y 3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Tfno.:&nbsp;&nbsp;&nbsp; 341 6312032
<BR>&nbsp; Las Rozas&nbsp; 28230 MADRID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Fax:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 341 6312128
<BR>&nbsp;</HTML>

--------------7B14D832AFE4658630F7B08E--
Technical Details
Message-ID: <357C20BD.2358B2A6@es.oracle.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: 1116f3,a3c8dbc960e99480,start
X-Google-Attributes: gid1116f3,public
From: Javier Iglesias <figlesia@es.oracle.com>
Subject: Usar metodo PUT
Date: 1998/06/08
Message-ID: <357C20BD.2358B2A6@es.oracle.com>
X-Deja-AN: 360742843
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="------------7B14D832AFE4658630F7B08E"
Organization: Oracle Iberica S.R.L.
Newsgroups: es.comp.lenguajes.java