Article View: es.comp.lenguajes.java
Article #28136Usar metodo PUT
From: Javier Iglesias
Date: Mon, 08 Jun 1998 00:00
Date: Mon, 08 Jun 1998 00:00
183 lines
10548 bytes
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í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.
<P>Os adjunto el código por si os funcionara.
<BR>
<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>
public static void main(String[] args) {</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>
// Sintax:</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>
// java.exe upload.URLTest URLdestino Documento Proxy</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>
if ( (args.length < 2) && (args.length >3) ) {</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>
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>
return;</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>
}</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>
// Mostramos los parámetros</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>
System.err.println("Parámetros:(0,1,2)->"+ args[0]+","+</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>
args[1]+","+args[2]);</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>
// Comenzamos las conexiones</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>
try {</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>
URL u = new URL(args[0]);</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>
URLConnection uc = u.openConnection();</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>
uc.setAllowUserInteraction(true);</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>
uc.setRequestProperty("Authorization", "Basic ZGVtbzpkZW1v");</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>
uc.setDoOutput(true);</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>
uc.connect();</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>//
BufferedReader br = new BufferedReader(</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>//
new InputStreamReader(uc.getInputStream()));</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>
BufferedWriter bw = new BufferedWriter(</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>
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>
String line;</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>
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>
bw.flush();</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>
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>
/* while ((line=br.readLine())!=null) {</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>
System.out.println("line="+line);</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>
}</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>
*/</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>
}</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>
catch(Exception e) {</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>
e.printStackTrace();</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>
}</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT COLOR="#000099"><FONT SIZE=-2>
}</FONT></FONT></FONT>
<BR><FONT FACE="Courier New,Courier"><FONT SIZE=-2></FONT></FONT>
<BR>
<P>Saludos, Javier.
<P>--
<BR>______________________________________________________________
<BR> __ __ _ __
__
<BR> (__) |-< /-\(__ |__(-_ Ibérica, S.R.L.
<BR> Javier Iglesias
<A HREF="http://www.oracle.es">http://www.oracle.es</A>
<BR> Sales Consultant
Internet: figlesia@es.oracle.com
<BR> C/ Navaluenga 1 y 3
Tfno.: 341 6312032
<BR> Las Rozas 28230 MADRID
Fax: 341 6312128
<BR> </HTML>
--------------7B14D832AFE4658630F7B08E--
Technical Details
Message-ID:
<357C20BD.2358B2A6@es.oracle.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow 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