B4J Question How to create a File object ? (FileSystemView)

jmon

Well-Known Member
Licensed User
Longtime User
Hello,

I am trying to convert some functions on this page : http://docs.oracle.com/javase/7/docs/api/javax/swing/filechooser/FileSystemView.html

B4X:
Public Sub isDrive(Path As String) As Boolean
    Dim FileJO As JavaObject
    FileJO.InitializeStatic("java.io.File")
   
    Dim FileSystemView As JavaObject
    FileSystemView.InitializeStatic("javax.swing.filechooser.FileSystemView")
    FileJO = FileSystemView.RunMethod("createFileObject", Array As String(Path))
   
    Return FileSystemView.RunMethod("isDrive", Array As Object(FileJO))
End Sub

Sub AppStart (Args() As String)
    Log(isDrive("C:\"))

End Sub

But with this code, I get this error :
I don't get it. I tried so many variations of this code, but no luck so far.

Thanks for your help.
jmon
 

jmon

Well-Known Member
Licensed User
Longtime User
Thanks,

With this new code I am getting a different error :
B4X:
Public Sub isDrive(Path As String) As Boolean
    Dim FileSystemView As JavaObject
    FileSystemView.InitializeStatic("javax.swing.filechooser.FileSystemView")
    FileSystemView = FileSystemView.RunMethod("getFileSystemView", Null)
   
    Dim FileJO As JavaObject
    FileJO = FileSystemView.RunMethod("createFileObject", Array As Object(Path))
   
    Return FileSystemView.RunMethod("isDrive", Array As Object(FileJO))
End Sub


The error happens on the "createFileObject" method. Any idea?

Thanks
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…