I'm writing to code in Android Studio, but I have a problem. I would like to access to exist file on windows shares. Unfornately when I debugging or running the code, it is not working for me. I know that emulator is not same network, but I downloaded ping app and I sent ping, imcp to server what worked. I downloaded jcifs-1.3.19.jar then I imported in project, but always stuck at one point.
SmbFileInputStream in = new SmbFileInputStream("smb://host/c/My Documents/somefile.txt", auth);
This code is from the official site. https://www.jcifs.org/src/docs/api/
I've tried it in many ways. Why is not working on emulator?
import jcifs.smb.*;
try{
jcifs.Config.setProperty( "jcifs.netbios.wins", "192.168.1.220" );
NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("domain", "username", "password");
SmbFileInputStream in = new SmbFileInputStream("smb://host/c/My Documents/somefile.txt", auth);
byte[] b = new byte[8192];
int n;
while(( n = in.read( b )) > 0 ) {
System.out.write( b, 0, n );
}
}
catch(Exeption e)
{}
Any help is appreciated.
What is the target server? JCIFS can connect to a server only when the server supports SMBv1. New Windows 10 OSs do not support this protocol. If you need a Java SMB library that can connect to Windows 10, look for the jNQ library (commercial license).