Android 區域網路 - JCIFS Library
在Android 機器上想要讀取Windows 或 Linux 網路芳鄰中檔案時,
可使用第三方Library : Jcifs 來實現.
Jcifs 屬於 LGPL License, 只要不更改到 Jcifs 相關source code就不須將Souce Code 公開.
但Jcifs目前只支援smb 1,不支援smb 2/smb 3。若要支援smb 2/3 可使用
Step 1: 取得 Jcifs jar 檔案
可從官網 :https://jcifs.samba.org/ 下載 jar 檔.
將jar檔案複製到 /project_name/libs 中
Step 2: 設定 Library
在Project檔案列表中, 在libs/jcifs-1.3.19.jar按右鍵, 選擇 Add to Library
Step 3: 取得遠端檔案
無使用者帳號密碼
String remoteURL = “smb://192.168.0.155”;
SmbFile dir = new SmbFile(remoteURL);需要使用者帳號密碼
NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(null, userName, password);
String remoteURL = “smb://192.168.0.155”;
SmbFile dir = new SmbFile(remoteURL, auth);
Step 4: 下載遠端檔案
1 | String remoteURL = "smb://192.168.0.155"; |
Android 區域網路 - JCIFS Library
https://nickcarter9.github.io/2019/04/08/2019/2019_04_08-jcifs/