B4J Question Error using su.SaveCSV(dirAppData, "Cashflow2.csv", ",", lstdata)

Mikelgiles

Active Member
Licensed User
I modified code from EditableTable.bas from the forum to meet my needs and everything works fine until using su.SaveCSV(dirAppData, "Cashflow2", ",", lstdata) where it errors. I am 99% sure that the values in dirAppData and lstdata are OK but I suspect that I am missing something somewhere

B4X:
Public Sub ExportTableToCSV
    Dim lstdata As List
    lstdata.Initialize
    Dim rs As ResultSet = B4XTableM.sql1.ExecQuery("SELECT * FROM data")
    Do While rs.NextRow
        Dim row(B4XTableM.Columns.Size) As String
        For i = 0 To B4XTableM.Columns.Size - 1
            Dim c As B4XTableColumn = B4XTableM.Columns.Get(i)
            row(i) = rs.GetString(c.SQLID)
        Next
        lstdata.Add(row)
    Loop
    rs.Close   'lstdata looks to be totally legitimate
    Dim su As StringUtils
    Try
        su.SaveCSV(dirAppData, "Cashflow2.csv", ",", lstdata)   'error happens here
    Catch
        Log("========" &  LastException.Message & "========")
   End Try
End Sub
B4X:
LOG file
Waiting for debugger to connect...
Program started.
Error occurred on line: 453
java.lang.NullPointerException
    at java.base/java.util.regex.Matcher.getTextLength(Matcher.java:1770)
    at java.base/java.util.regex.Matcher.reset(Matcher.java:416)
    at java.base/java.util.regex.Matcher.<init>(Matcher.java:253)
    at java.base/java.util.regex.Pattern.matcher(Pattern.java:1133)
    at anywheresoftware.b4a.objects.StringUtils.Word(StringUtils.java:97)
    at anywheresoftware.b4a.objects.StringUtils.SaveCSV2(StringUtils.java:88)
    at anywheresoftware.b4a.objects.StringUtils.SaveCSV(StringUtils.java:67)
    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.runVoidMethod(Shell.java:676)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:240)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
    at jdk.internal.reflect.GeneratedMethodAccessor12.invoke(Unknown Source)
    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.debug.Debug.delegate(Debug.java:64)
    at b4j.example.main._exporttabletocsv(main.java:649)
    at b4j.example.main._mainform_closed(main.java:1055)
    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:237)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
    at jdk.internal.reflect.GeneratedMethodAccessor12.invoke(Unknown Source)
    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$1.run(BA.java:216)
    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)
========java.lang.Exception:  java.lang.NullPointerException========
 
Top