I ian2410 Member Licensed User Apr 7, 2017 #1 Hi, I'm Ian and newbie with B4A. I can send string to PC but I have a problem sending text file to PC (with B4J server). I'm using a tablet with Android version 6.0. java.io.FileNotFoundException: /data/user/0/b4a.example/files/temp.text: open failed: ENOENT (No such file or directory) at libcore.io.IoBridge.open(IoBridge.java:487) at java.io.FileInputStream.<init>(FileInputStream.java:76) at anywheresoftware.b4a.objects.streams.File.OpenInput(File.java:209) at anywheresoftware.b4a.samples.httputils2.httpjob._postfile(httpjob.java:235) at b4a.example.cekorder._button4_click(cekorder.java:708) at java.lang.reflect.Method.invoke(Native Method) at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710) at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:339) at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249) at java.lang.reflect.Method.invoke(Native Method) at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:167) at anywheresoftware.b4a.BA.raiseEvent(BA.java:163) at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:78) at android.view.View.performClick(View.java:5265) at android.view.View$PerformClick.run(View.java:21534) at android.os.Handler.handleCallback(Handler.java:815) at android.os.Handler.dispatchMessage(Handler.java:104) at android.os.Looper.loop(Looper.java:207) at android.app.ActivityThread.main(ActivityThread.java:5728) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679) Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory) at libcore.io.Posix.open(Native Method) at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186) at libcore.io.IoBridge.open(IoBridge.java:473) mycode : Dim Job As HttpJob Job.Initialize("Job", Me) Job.JobName = "Sent" Job.PostFile(link2, File.DirRootExternal, "temp.text") i'm sure that "temp.text" is exist cause i can open the "temp.text" with File.ReadString. Any advice ? Thanks a lot.
Hi, I'm Ian and newbie with B4A. I can send string to PC but I have a problem sending text file to PC (with B4J server). I'm using a tablet with Android version 6.0. java.io.FileNotFoundException: /data/user/0/b4a.example/files/temp.text: open failed: ENOENT (No such file or directory) at libcore.io.IoBridge.open(IoBridge.java:487) at java.io.FileInputStream.<init>(FileInputStream.java:76) at anywheresoftware.b4a.objects.streams.File.OpenInput(File.java:209) at anywheresoftware.b4a.samples.httputils2.httpjob._postfile(httpjob.java:235) at b4a.example.cekorder._button4_click(cekorder.java:708) at java.lang.reflect.Method.invoke(Native Method) at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710) at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:339) at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249) at java.lang.reflect.Method.invoke(Native Method) at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:167) at anywheresoftware.b4a.BA.raiseEvent(BA.java:163) at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:78) at android.view.View.performClick(View.java:5265) at android.view.View$PerformClick.run(View.java:21534) at android.os.Handler.handleCallback(Handler.java:815) at android.os.Handler.dispatchMessage(Handler.java:104) at android.os.Looper.loop(Looper.java:207) at android.app.ActivityThread.main(ActivityThread.java:5728) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679) Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory) at libcore.io.Posix.open(Native Method) at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186) at libcore.io.IoBridge.open(IoBridge.java:473) mycode : Dim Job As HttpJob Job.Initialize("Job", Me) Job.JobName = "Sent" Job.PostFile(link2, File.DirRootExternal, "temp.text") i'm sure that "temp.text" is exist cause i can open the "temp.text" with File.ReadString. Any advice ? Thanks a lot.
R ronell Well-Known Member Licensed User Longtime User Apr 7, 2017 #2 add this code before the job Code: If File.Exists(File.DirRootExternal,"temp.txt") = False Then File.WriteString(File.DirRootExternal,"temp.txt", _ "") Else End If Upvote 0
add this code before the job Code: If File.Exists(File.DirRootExternal,"temp.txt") = False Then File.WriteString(File.DirRootExternal,"temp.txt", _ "") Else End If
R ronell Well-Known Member Licensed User Longtime User Apr 7, 2017 #4 take a look at the error java.io.FileNotFoundException: /data/user/0/b4a.example/files/temp.text: open failed: ENOENT (No such file or directory) Click to expand... temp.txt is being search in your project folder(assets)? edit: i test it with this code , without the file in DirRootExternal.. Code: Dim job As HttpJob job.Initialize("job1",Me) job.PostFile("link",File.DirRootExternal,"sample.txt") error: java.io.FileNotFoundException: /storage/sdcard0/sample.txt: open failed: ENOENT (No such file or directory) Click to expand... Last edited: Apr 7, 2017 Upvote 0
take a look at the error java.io.FileNotFoundException: /data/user/0/b4a.example/files/temp.text: open failed: ENOENT (No such file or directory) Click to expand... temp.txt is being search in your project folder(assets)? edit: i test it with this code , without the file in DirRootExternal.. Code: Dim job As HttpJob job.Initialize("job1",Me) job.PostFile("link",File.DirRootExternal,"sample.txt") error: java.io.FileNotFoundException: /storage/sdcard0/sample.txt: open failed: ENOENT (No such file or directory) Click to expand...
Erel B4X founder Staff member Licensed User Longtime User Apr 7, 2017 #5 Can you upload the project (File - Export as zip)? Upvote 0
I ian2410 Member Licensed User Apr 7, 2017 #6 My main purpose is to print "temp.text" which contains multi line text with printhtml. anyway, i've found another way to print that. i did this : EditText1.Text = File.ReadString(File.DirRootExternal, "temp.txt") then i just post it as string and now i can print multi line text successfully to 4 different printers simultaneously. Upvote 0
My main purpose is to print "temp.text" which contains multi line text with printhtml. anyway, i've found another way to print that. i did this : EditText1.Text = File.ReadString(File.DirRootExternal, "temp.txt") then i just post it as string and now i can print multi line text successfully to 4 different printers simultaneously.
R ronell Well-Known Member Licensed User Longtime User Apr 7, 2017 #7 but how come that the temp.txt is being search in your assets directory? Upvote 0
I ian2410 Member Licensed User Apr 7, 2017 #8 i don't know, ronell. same errors occurred if i try to delete or copy "temp.text" . "temp.text" is exist but somehow the file not found. Upvote 0
i don't know, ronell. same errors occurred if i try to delete or copy "temp.text" . "temp.text" is exist but somehow the file not found.
R ronell Well-Known Member Licensed User Longtime User Apr 7, 2017 #9 see erels post so the main issue can be solve .. im also curious about the problem Upvote 0
I ian2410 Member Licensed User Apr 7, 2017 #10 i made a new one. just to test sending file. still can't sent or delete file Attachments test.zip test.zip 8.4 KB · Views: 550 Upvote 0
R ronell Well-Known Member Licensed User Longtime User Apr 7, 2017 #11 in activity create .. you are copying the file in dirInternal, change it to DirRootExternal in Sent button(button3_click) , change the file name to temp.txt , not temp.text Code: Activity.LoadLayout("Main") If File.Exists(File.DirRootExternal, "temp.txt") = False Then File.Copy(File.DirAssets, "temp.txt", File.DirRootExternal, "temp.txt") End If Code: Sub Button3_Click Dim job As HttpJob job.Initialize("job", Me) job.JobName = "Sent" job.PostFile(link, File.DirRootExternal,"temp.txt") End Sub Attachments testapp.zip testapp.zip 8.4 KB · Views: 587 Last edited: Apr 7, 2017 Upvote 0
in activity create .. you are copying the file in dirInternal, change it to DirRootExternal in Sent button(button3_click) , change the file name to temp.txt , not temp.text Code: Activity.LoadLayout("Main") If File.Exists(File.DirRootExternal, "temp.txt") = False Then File.Copy(File.DirAssets, "temp.txt", File.DirRootExternal, "temp.txt") End If Code: Sub Button3_Click Dim job As HttpJob job.Initialize("job", Me) job.JobName = "Sent" job.PostFile(link, File.DirRootExternal,"temp.txt") End Sub
I ian2410 Member Licensed User Apr 7, 2017 #12 sorry for my mistake in the sample. but in my actual app, i type it right. i've tried yours... java.io.FileNotFoundException: /storage/sdcard0/temp.txt: open failed: ENOENT (No such file or directory) at libcore.io.IoBridge.open(IoBridge.java:496) at java.io.FileInputStream.<init>(FileInputStream.java:76) at anywheresoftware.b4a.objects.streams.File.OpenInput(File.java:209) at anywheresoftware.b4a.objects.streams.File.ReadString(File.java:271) at b4a.example.main._button2_click(main.java:448) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710) at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:342) at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:167) at anywheresoftware.b4a.BA.raiseEvent(BA.java:163) at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:78) at android.view.View.performClick(View.java:4848) at android.view.View$PerformClick.run(View.java:20262) at android.os.Handler.handleCallback(Handler.java:815) at android.os.Handler.dispatchMessage(Handler.java:104) at android.os.Looper.loop(Looper.java:194) at android.app.ActivityThread.main(ActivityThread.java:5637) Upvote 0
sorry for my mistake in the sample. but in my actual app, i type it right. i've tried yours... java.io.FileNotFoundException: /storage/sdcard0/temp.txt: open failed: ENOENT (No such file or directory) at libcore.io.IoBridge.open(IoBridge.java:496) at java.io.FileInputStream.<init>(FileInputStream.java:76) at anywheresoftware.b4a.objects.streams.File.OpenInput(File.java:209) at anywheresoftware.b4a.objects.streams.File.ReadString(File.java:271) at b4a.example.main._button2_click(main.java:448) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710) at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:342) at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:167) at anywheresoftware.b4a.BA.raiseEvent(BA.java:163) at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:78) at android.view.View.performClick(View.java:4848) at android.view.View$PerformClick.run(View.java:20262) at android.os.Handler.handleCallback(Handler.java:815) at android.os.Handler.dispatchMessage(Handler.java:104) at android.os.Looper.loop(Looper.java:194) at android.app.ActivityThread.main(ActivityThread.java:5637)
I ian2410 Member Licensed User Apr 7, 2017 #13 but it works in android 5.0, failed in android 6.0. finally, it works when i set : android:maxSdkVersion="22" previously "23". don't know why. Thanks a lot Last edited: Apr 7, 2017 Upvote 0
but it works in android 5.0, failed in android 6.0. finally, it works when i set : android:maxSdkVersion="22" previously "23". don't know why. Thanks a lot
DonManfred Expert Licensed User Longtime User Apr 7, 2017 #14 If you use Api 23 you MUST USE RUNTIMEPERMISSIONS Library and request Permission for any "dangerous Permission" like write on external storage Upvote 0
If you use Api 23 you MUST USE RUNTIMEPERMISSIONS Library and request Permission for any "dangerous Permission" like write on external storage