B4J Question Problem accessing File.DirData (FileNotFoundException) [solved, nasty...]

Didier9

Well-Known Member
Licensed User
Longtime User
This line of code:
B4X:
su.SaveCSV2( File.DirData( AppName ), vers, ",", lstCSV, hdr )
where
B4X:
vers = "C1A0501 v0.4.0 FAN 2021-10-11 094328.csv"
AppName = "R9_B4J"
causes this error:
B4X:
Error occurred on line: 3817 (Main)
java.io.FileNotFoundException: C:\Users\<my user name>\AppData\Roaming\R9_B4J\C1A0501 v0.4.0 FAN 2021-10-11 094328.csv (The filename, directory name, or volume label syntax is incorrect)
    at java.io.FileOutputStream.open0(Native Method)
    at java.io.FileOutputStream.open(FileOutputStream.java:270)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
    at anywheresoftware.b4a.objects.streams.File.OpenOutput(File.java:439)
    at anywheresoftware.b4a.objects.streams.File.WriteString(File.java:259)
    at anywheresoftware.b4a.objects.StringUtils.SaveCSV2(StringUtils.java:92)
    at b4j.r9_b4j.main$ResumableSub_mSaveToCSV_Action.resume(main.java:20209)
    at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:47)
    at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    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 sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    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 anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:42)
    at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:136)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:85)
    at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
    at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:487)
    at anywheresoftware.b4a.keywords.Common.access$0(Common.java:467)
    at anywheresoftware.b4a.keywords.Common$CallSubDelayedHelper.run(Common.java:541)
    at com.sun.javafx.application.PlatformImpl.lambda$null$5(PlatformImpl.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$6(PlatformImpl.java:294)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$4(WinApplication.java:186)
    at java.lang.Thread.run(Thread.java:748)

The same line of code on the previous run of this program worked fine (for the last ~3 years) and I have made no change to those functions in a while, I have several similar usage of File.DirData in the program and they all crash now :(

Of course, the folder "AppData\Roaming\R9_B4J" is still there and since I am creating the file, it is unexpected to get java.io.FileNotFoundException

Any help appreciated!

Additional information: the previous version of this application still runs fine with the same line of code on the same machine, something else must have changed in this version that causes the problem, but while I made a few changes, none were intended to affect file system access. I did use BeyondCompare to compare the file that works and the one that does not and the changes have nothing to do with file or directory access. The app is quite big so I am reluctant to post it in it's entirety.
 
Last edited:

Didier9

Well-Known Member
Licensed User
Longtime User
I think I found the problem, there was a non-printable character in the file name, so it did not show anywhere...

I found it by trying to create a small project showing the problem. When I copied the filename from the B4J error message Logs window into the forum editor, it showed the typical rectangle that is sometime displayed by software when there is a non-printable character. That's the only place where I could see it (it is right after the word "FAN").

Non-printable character in file name.png


but you can't see it when you look at the forum post, it only shows in Edit mode:

java.io.FileNotFoundException: C:\Users\<user name>\AppData\Roaming\R9_B4J\C1A0501 v0.4.0 FAN 2021-10-11 155714.html (The filename, directory name, or volume label syntax is incorrect)

Interestingly, it only shows the rectangle when I am editing the comment, and does not show it in the Preview window or in the forum.
 
Last edited:
Upvote 0
Top