The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
April 2001

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

How to use URL Connection for creating a new file/writing into an existing file.

Posted by V.K on June 13, 2001 at 10:23 AM

I am trying to open a new file on remote m/c on the intranet. I am using following code.

URL url = new URL ("ftp://user:passwd@machine_name/dir1/dir2/testFile.dat");
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
PrintStream outStream = new PrintStream
(conn.getOutputStream());
outStream.print("This is a test record 1");
outStream.flush();
outStream.close();


There is no compilation error but when I execute this code I get an exception
"java.net.UnknownServiceException: protocol doesn't support output"

Help is appreciated.




Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us