help me to read a file from another machine in the network.

Reply

Join Date: Jan 2008
Posts: 71
Reputation: ajithraj is an unknown quantity at this point 
Solved Threads: 1
ajithraj ajithraj is offline Offline
Junior Poster in Training

help me to read a file from another machine in the network.

 
0
  #1
Dec 13th, 2008
haii
I have a requirement in which i want to read a file from another
machine in the network.
I want to know how to set the URL

Thanks in advance
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 1,175
Reputation: stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light 
Solved Threads: 125
Featured Poster
stephen84s's Avatar
stephen84s stephen84s is offline Offline
Veteran Poster

Re: help me to read a file from another machine in the network.

 
0
  #2
Dec 13th, 2008
And how exactly is the target file shared on the network ?? FTP, HTTP ?? or just by SMB (Windows Sharing) ??

You need to divulge more details as to what exactly are you trying to achieve.

Also although I know its useless saying this but still read this essay and learn how to frame your questions on a forum like this, it is you who will benefit most because if you ask questions correctly or ask the correct questions, more people will feel like answering to your query.
Last edited by stephen84s; Dec 13th, 2008 at 9:28 am.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."

"How to ask questions the smart way ?"
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 822
Reputation: verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough 
Solved Threads: 73
verruckt24's Avatar
verruckt24 verruckt24 is offline Offline
Practically a Posting Shark

Re: help me to read a file from another machine in the network.

 
0
  #3
Dec 13th, 2008
As mentioned above how is the file shared ? But more importantly whats this got to do with Java ? Please put your question in proper context so that we are able to understand and in turn help you better.
Get up every morning and take a look at the Forbes' list of richest people. If your name doesn't appear.... GET TO WORK !!!
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 71
Reputation: ajithraj is an unknown quantity at this point 
Solved Threads: 1
ajithraj ajithraj is offline Offline
Junior Poster in Training

Re: help me to read a file from another machine in the network.

 
0
  #4
Dec 15th, 2008
really Sorry .....and thanks for answering me....

I want to read an image from a machine in network using http...
Actually my need is to read the image from a system and to store this in another one
I know that it can be done only by setting the Url..


///verruckt24:::But more importantly whats this got to do with Java ?
I dont understand this...i want to access this from a java class
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 1,175
Reputation: stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light 
Solved Threads: 125
Featured Poster
stephen84s's Avatar
stephen84s stephen84s is offline Offline
Veteran Poster

Re: help me to read a file from another machine in the network.

 
0
  #5
Dec 15th, 2008
Originally Posted by ajithraj
///verruckt24:::But more importantly whats this got to do with Java ?
I dont understand this...i want to access this from a java class
Verruckt asked that because you simply had forgotten to mention that fact.

Originally Posted by ajithraj
I know that it can be done only by setting the Url..
I do not what you are talking about here, but to access files over HTTP you will definitely be needing the URL and URLConnection classes. They can be used connect to URLs over an HTTP connection.

Here is an example that deals with text files.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."

"How to ask questions the smart way ?"
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 71
Reputation: ajithraj is an unknown quantity at this point 
Solved Threads: 1
ajithraj ajithraj is offline Offline
Junior Poster in Training

Re: help me to read a file from another machine in the network.

 
0
  #6
Dec 15th, 2008
Thanksss.. But i still have problems..


The code i wrote is :::
URL hp = new URL("http", "www.rediff.com", 80, "/");
URLConnection hpCon = hp.openConnection();


but hpCon.getContentLength() = -1....
It means that No Content is Available....

why this happens...
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 1,175
Reputation: stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light 
Solved Threads: 125
Featured Poster
stephen84s's Avatar
stephen84s stephen84s is offline Offline
Veteran Poster

Re: help me to read a file from another machine in the network.

 
0
  #7
Dec 15th, 2008
To quote the Javadocs of URLConnection to which I had already linked to in the previous post :

1. The connection object is created by invoking the openConnection method on a URL.
2. The setup parameters and general request properties are manipulated.
3. The actual connection to the remote object is made, using the connect method.
4. The remote object becomes available. The header fields and the contents of the remote object can be accessed.
So you need to first connect and then check whether the content is available.
Last edited by stephen84s; Dec 15th, 2008 at 2:58 am.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."

"How to ask questions the smart way ?"
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 33
Reputation: AlbertPi is an unknown quantity at this point 
Solved Threads: 2
AlbertPi AlbertPi is offline Offline
Light Poster

Re: help me to read a file from another machine in the network.

 
0
  #8
Dec 15th, 2008
  1. public void URLReader(){
  2. try{
  3. URL logic = new URL("http://your host name & port number/folder/");
  4. BufferedReader in = new BufferedReader(new InputStreamReader(logic.openStream()));
  5.  
  6. String inputLine;
  7.  
  8. while ((inputLine = in.readLine()) != null)
  9. System.out.println(inputLine);
  10.  
  11. in.close();
  12. }
  13. catch (MalformedURLException e) {
  14. System.out.println ("Malformed URL= "+e);
  15. }
  16. catch (IOException e) {
  17. System.out.println ("IO Exception = "+e);
  18.  
  19. }
  20.  
  21. Albert
  22. }
Last edited by cscgal; Dec 15th, 2008 at 6:08 pm. Reason: Added code tags
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,427
Reputation: Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of 
Solved Threads: 507
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

Re: help me to read a file from anothermachine in the network.

 
0
  #9
Dec 15th, 2008
AlbertPi, please use [code] [/code] tags if you are going to post code examples.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 71
Reputation: ajithraj is an unknown quantity at this point 
Solved Threads: 1
ajithraj ajithraj is offline Offline
Junior Poster in Training

Re: help me to read a file from another machine in the network.

 
0
  #10
Dec 16th, 2008
okk...this is what i too is trying now..but since my connection is through a proxy server i want to add its IP..but the problem is that how can i get the IP adress of my proxy server...

Thanks..
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC