Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to Login to a machine and download files?

 
Sajee Joseph
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,
I have a set of images on a machine (windows machine) on my Intranet. Let me refer this machine as 'A'.
I have an application Hosted on Tomcat on another Machine (windows machine). Let me refer this machine as 'B'.
Now i have the Java code to retrieve the images from A to B. But as a pre-requisite i need to 'Login' to A before i run the java code. If i dont login, i get the below mentioned error:
java.io.FileNotFoundException: \\192.168.2.171\images\4d_H.gif (Logon failure: unknown user name or bad password).
Can I login using My java application rather than manually login ( I know the login credential to this machine). Is there any means to specify my Login credentials via my java application?
Please help me out.
The code that i use to downlaod the images is somewhat like this:
File fileIn = new File("\\\\192.168.2.171\\images\\4d_H.gif"); //insert your file name here.
FileInputStream in = new FileInputStream(fileIn);
File fileOut = new File("d:\\MyJavaPrograms\\hellloooooo.gif");
FileOutputStream out = new FileOutputStream(fileOut);
byte[] buffer = new byte[10000];
int length;
while ((length = in.read(buffer)) != -1)
{
out.write(buffer, 0, length);
}
in.close();
out.close();
Thanks,
Sajee Joseph
 
Adrian Yan
Ranch Hand
Posts: 688
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are in a window environment, you would want this package, it does all the thing you mentioned. JCIFS
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!