1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("adresseIP", "id", "mdp");
SmbSession.logon(new UniAddress(InetAddress.getByName("adresseIP")), auth);
//Copy to Server
File androFile = new File(Environment.getExternalStorageDirectory() + "/Documents/java-intro.pdf");
FileInputStream fis = new FileInputStream(androFile);
SmbFile file = new SmbFile("smb://adresseIP/partages/java-intro.pdf",auth);
SmbFileOutputStream smbOut = new SmbFileOutputStream(file);
byte[] outBuffer = new byte[1024];
int n;
while((n = fis.read(outBuffer))!=-1){
smbOut.write(outBuffer, 0, n);
}
fis.close();
smbOut.close(); |