Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Writing to a file on the server whose URL is given

 
Vinitra Ramji
Greenhorn
Posts: 10
Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any idea how to write/edit/modify a file that is on the server and I have the URL to that file?
 
Thakur Sachin Singh
Ranch Hand
Posts: 248
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all you have access right or not, this matter when you write the file.
 
Vinitra Ramji
Greenhorn
Posts: 10
Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thakur Sachin Singh wrote:First of all you have access right or not, this matter when you write the file.

I have the permission to write. But how do I go about it?
 
Abhay Agarwal
Ranch Hand
Posts: 1376
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you can create a File object using its URI constructor.Then you can use File object's method to modify that file.

 
Paul Clapham
Sheriff
Posts: 21126
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, sorry, a File object refers to a file on the local system. So that's completely incorrect.

To Vinitra: you didn't say what kind of URL you had. You can't update a file via an HTTP URL. If it were an FTP URL, you probably could.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64967
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or perhaps it's not HTTP but WebDAV you seek.
 
Vinitra Ramji
Greenhorn
Posts: 10
Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is a http URL.. Isnt there any way by which it can be done? It is located on a remote server and has to be accessed using http.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64967
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, so it seems you need to write some servlets to do what you want to do with the files.
 
Vinitra Ramji
Greenhorn
Posts: 10
Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:OK, so it seems you need to write some servlets to do what you want to do with the files.


How am I supposed to go about this? I want to know the methods/objects to use.
 
Vinitra Ramji
Greenhorn
Posts: 10
Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am able to read the contents of the file, given the URL but modifying the contents and writing it back to the url is the problem!
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vinitra Ramji wrote:How am I supposed to go about this? I want to know the methods/objects to use.

Do you know how to write servlets in general? Do you know how to use the java.io package to manipulate/write the file in the way that you need? If the answer to both is "yes", can you combine both? If the answer is "no" to either of these, I'd start by learning that particular skill.

The servlet would, of course, have to run on the remote server - do you have control over that server, so that you can run servlets there?
 
Vinitra Ramji
Greenhorn
Posts: 10
Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:
Vinitra Ramji wrote:How am I supposed to go about this? I want to know the methods/objects to use.

Do you know how to write servlets in general? Do you know how to use the java.io package to manipulate/write the file in the way that you need? If the answer to both is "yes", can you combine both? If the answer is "no" to either of these, I'd start by learning that particular skill.

The servlet would, of course, have to run on the remote server - do you have control over that server, so that you can run servlets there?


I know to write servlets in general and I also know to use java.io package but combining the both I am just able to read from the file on the remote server; not able to write.

And about the server you are asking about, I have control over that server to some extent. Like I can move around the files on the server etc.
 
Vinitra Ramji
Greenhorn
Posts: 10
Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:No, sorry, a File object refers to a file on the local system. So that's completely incorrect.

To Vinitra: you didn't say what kind of URL you had. You can't update a file via an HTTP URL. If it were an FTP URL, you probably could.


How would I go about it if I had a FTP URL?

PS: I'm completely new to FTP
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Apache Commons Net is a good FTP client library.
 
Vinitra Ramji
Greenhorn
Posts: 10
Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:Apache Commons Net is a good FTP client library.

Thank you! I'll look through it and get back to you, if I dont find any solution!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic