Pages

Wednesday, September 01, 2010

Connect to Remote file in Java

sometimes, you need to put a file or more into remote computer for any purpose according to your application. in java, you can use code like this:
String url = "smb://yourhost/yourpath/";
NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(null, "user", "password");
SmbFile dir = new SmbFile(url, auth);
for (SmbFile f : dir.listFiles())
{
System.out.println(f.getName());
}




No comments:

Post a Comment