This is probably me, but I just don't see it and it is driving me nuts:
Running this code:
Is the List we get back from File.ListFiles somehow not a normal B4J list?
My workaround currently is using a third list, but I'm just wondering what could be wrong.
Alwaysbusy
Running this code:
B4X:
Dim files As List = File.ListFiles(File.Combine(File.DirApp, "VR/moviesR/"))
For i = 0 To files.Size - 1
files.Set(i, files.Get(i) & "$R")
Next
' here a load files from another folder
Dim filesT As List = File.ListFiles(File.Combine(File.DirApp, "VR/moviesT/"))
For i = 0 To filesT.Size - 1
' and want to add them to the first one
files.Add(filesT.Get(i) & "$T") '<--- immidiately fails here with the error
Next
B4X:
Error occurred on line: 64 (Main)
java.lang.UnsupportedOperationException
at java.base/java.util.AbstractList.add(AbstractList.java:153)
at java.base/java.util.AbstractList.add(AbstractList.java:111)
at anywheresoftware.b4a.objects.collections.List.Add(List.java:71)
at b4j.example.main._appstart(main.java:166)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:632)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:234)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:78)
at b4j.example.main.start(main.java:38)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
at java.base/java.lang.Thread.run(Thread.java:834)
Is the List we get back from File.ListFiles somehow not a normal B4J list?
My workaround currently is using a third list, but I'm just wondering what could be wrong.
B4X:
Dim files As List
files.Initialize
Dim filesR As List = File.ListFiles(File.Combine(File.DirApp, "VR/moviesR/"))
For i = 0 To filesR.Size - 1
files.Add(filesR.Get(i) & "$R")
Next
Dim filesT As List = File.ListFiles(File.Combine(File.DirApp, "VR/moviesT/"))
For i = 0 To filesT.Size - 1
files.Add(filesT.Get(i) & "$T")
Next
Alwaysbusy