0

I need to read a remote file using a java app, but the file is in apache server on linux. I tried with "\\" but doesn't work like windows. How can i do that?

1

3 Answers 3

3

You'll need to use the URL class: http://download.oracle.com/javase/1.4.2/docs/api/java/net/URL.html

This is the standard way of reading files from a URL.

Sign up to request clarification or add additional context in comments.

Comments

1

Try accessing your file via web browser using url formatted like:

http://server-name-or-ip/path/filename

When you see your file in browser, use that url from your Java app, too.

Comments

0

This depends on a number of things. But we don't really know what question you're asking. Are you asking how to retrieve a document over HTTP? How to do a file copy from Linux? Network shares?

If the file is served by the webserver (in the docroot), the easiest way is probably to request it over HTTP using the URL class as stated above.

If the file is NOT under the webroot (i.e. can't be specified as http://webserver.name/some/path/to/file) then you'll need to use some other method. I'm assuming this is what you meant - you mention \\, the Windows file-sharing (SMB) protocol prefix. The easiest way is to use SSH and scp/sftp, which is probably already installed on the Linux machine - you may need to enable it, and you'll need a login. Then it's as simple as scp user@host:/remote/file/path local/path. You can set up SSH keys to avoid a password.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.