Hi.,
       Do u have any idea about file uploading in java. I have the following
code. Whats the wrong with it. Can u tell me. Plz.


DownLoad:
---------------
   try
   {
            URL u = new URL(args[i]);
            InputStream in = u.openStream();
            int ch=0;
            while ((ch =in.read())!=-1)
                 System.out.print((char) ch);
           in.close();
         }
   catch (Exception e)
   {}

Prints the contents of the server into the console. It ok.

UpLoad:
======
    try
    {
           URL url = new URL(args[i]);
           URLConnection con =  url.openConnection();
           con.setDoOutput(true);
//    con.connect();
           OutputStream os = new con.getOutputStream();
           byte[] src = "Hello World".getBytes();
           os.write(src);
           os.close();
         }
   catch (Exception e)
   {
    System.err.println(e);
   }
There is no error but the contents or not stored in the file at the server
which is Tomcat in this case. When try to write in HDD it is stored to the
specified file.

Do u have any soutions for this.

Rgds
Vijay.

Reply via email to