I'm using JCIFS in my new Android project. Somehow I've decided to use URL class to generalized the file path (so I can add more protocol later). What I did is as below
URL url = new URL("smb://192.168.1.1/filepath");
And then 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 JCIFS FAQ reveals that I have to register the protocol before using the class. However I don't really know how to do so in Android. I think the library do this already, but it doesn't on Android.
So what should I do ?
I've just saw the usage in JCIFS reference, in the SmbFile reference.
When using the java.net.URL class with 'smb://' URLs it is necessary to first call the static jcifs.Config.registerSmbURLHandler(); method. This is required to register the SMB protocol handler.
So I add this call and it works properly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With