Seventeen Stars

protocole SMB :: Samba

Sometime i have to get data from OS windows ; i've got a a samba "partage" with it to retrieve them ... manually.
So it will be helpfully to access those repositories by protocole smb:// .............
thanks for your attention

Re: protocole SMB :: Samba

Here is a java routine that will help you.
In order to use it, you will need to download the jcifs library from and add it to the routine libraries (Right Click on the routine, Edit Routine Libraries)
If you find it interesting, you can ask for a feature request on tFileFetch component to support smb protocol.
// template routine Java
package routines;
import jcifs.smb.*;

public class SambaTest {

private static void copySMBFile(String domain, String username, String password, String srcURL, String destFile){
try {
// To connect to a server on a remote subnet the IP address of a WINS server is required to retrieve the target address although DNS names and direct IP addresses are also valid server components within an SMB URL
// jcifs.Config.setProperty( "jcifs.netbios.wins", "" );

NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(domain, username, password);
//SmbFile(java.lang.String url, NtlmPasswordAuthentication auth)
SmbFile SF = new SmbFile(srcURL,auth);
SmbFileInputStream in = new SmbFileInputStream(SF);

File f2 = new File(destFile);
OutputStream out = new FileOutputStream(f2);

byte[] buf = new byte;
int len;
while ((len = > 0){
out.write(buf, 0, len);
} catch(FileNotFoundException ex) {
} catch(IOException e) {

public static void main(String[] args){
SambaTest.copySMBFile("domain", "username", "password", "smb://host/dir/distantfile.txt", "C:/localfile.txt");
Seventeen Stars

Re: protocole SMB :: Samba

thanks a lot mhirt
I didn't know anything about this library , and it 'll resolve some of my "problems" ...
In fact we're plan to migrate all applications on a OS linux but we can do all things we'd like to. (lol for my frenglish)
never mind , il'll going to try you code right now and effectively a tFileFech Smtp 'll be hepfully for some occasions
... seems to be

Re: protocole SMB :: Samba

Time to use the ;-)
Seventeen Stars

Re: protocole SMB :: Samba

your code works perfectly ...
I can now retrieve easily any files I want with "SMB" protocole with a tJavaFlex component (so simple)
routines.test.SMB_connection.runSMB(context.domain, context.username, context.password, context.srcURL, context.destFile);

PS : I've tried to add "a feature" in the bugtracker" but didn't find the way to (sic) !

Re: protocole SMB :: Samba

I have create feature request 5503
Seventeen Stars

Re: protocole SMB :: Samba

thanks a lot