Using SMB protocol in URL when using Android JCIFS library

I am using JCIFS in my new Android project. Somehow I decided to use the URL class to generalize the file path (so that I can add more protocol later). What I did as below

URL url = new URL("smb://192.168.1.1/filepath");

And then a java.net.MalformedURLException exception is thrown.

Exception in thread "main" java.net.MalformedURLException: unknown protocol: smb
    at java.net.URL.<init>(URL.java:184)
    at java.net.URL.<init>(URL.java:127)

Consulting Questions JCIFS shows that I must register a protocol before using the class. However, I really don't know how to do this in Android. I think the library is doing this already, but not on Android.

So what should I do?

+5
source share
2 answers

I just saw the use in the JCIFS link in the SmbFile link.

java.net.URL URL- "smb://" jcifs.Config.registerSmbURLHandler(); . SMB.

, , .

+5

URL. URL- SmbFile. :

SmbFile file = new SmbFile("smb://192.168.1.1/filepath");

, .

0

All Articles