Question, Why Error? - Open shared file

edited February 2017 in Android Mode

Hi, nice to meet you.

BufferedReader reader;
String line;
PFont font;

void setup() {
  font = createFont("aaaa.vlw", 32);

  size(1000,1500);
  // Open the file from the createWriter() example
  reader = createReader("positions.txt");    
}

void draw() {


  textFont(font);
  String[] lines22;
  lines22 = loadStrings("\\\\192.168.0.202\\share\\t1.txt");
  for (int i = 0; i < lines22.length; i = i+1) {
   text(lines22[i], 300, 200 + 100*i); 
  }

} 

Why is there no error in JAVA? But why is not it running on Android?   The concept is to share files through shared folders. And the status of the system is visible through the shared file.

Java mode works well. But Android mode does not work well. Why?

> blendMode(), or this particular variation of it, is not available with this renderer.

        positions.txt does not exist or could not be read
        The file "\\192.168.0.202\share\t1.txt" is missing or inaccessible, make sure the URL is valid or that the file has been added to your sketch and is readable.
        FATAL EXCEPTION: Animation Thread
        Process: processing.test.android_tcp, PID: 17405
        java.lang.NullPointerException: Attempt to get length of null array
          at processing.test.android_tcp.android_tcp.draw(android_tcp.java:38)
          at processing.core.PApplet.handleDraw(Unknown Source)
          at processing.core.PGraphicsAndroid2D.requestDraw(Unknown Source)
          at processing.core.PApplet.run(Unknown Source)
          at java.lang.Thread.run(Thread.java:818)</del>
Tagged:

Answers

  • @Gwak=== supposing the url is ok (because it is not the same in your code && the error code) have you added the internet permissions?

  • FATAL EXCEPTION: Animation Thread Process: processing.test.wee_company, PID: 9040 java.lang.IllegalArgumentException: File //Desktop-b2g9j3e/share/t1.txt contains a path separator at android.app.ContextImpl.makeFilename(ContextImpl.java:2322) at android.app.ContextImpl.openFileInput(ContextImpl.java:458) at android.content.ContextWrapper.openFileInput(ContextWrapper.java:191) at processing.core.PApplet.createInputRaw(Unknown Source) at processing.core.PApplet.createInput(Unknown Source) at processing.core.PApplet.loadStrings(Unknown Source) at processing.test.wee_company.WEE_Company.draw(WEE_Company.java:150) at processing.core.PApplet.handleDraw(Unknown Source) at processing.core.PGraphicsAndroid2D.requestDraw(Unknown Source) at processing.core.PApplet.run(Unknown Source) at java.lang.Thread.run(Thread.java:818)

  • Error message. In my opinion, I do not seem to be approaching. It seems that the document is not accessible. I gave permission to the Internet.

  •  String[] lines22;
     lines22 = loadStrings("//192.168.0.202\\share\\t1.txt");
     for (int i = 0; i < lines22.length; i = i+1) {
     text(lines22[i], 300, 200 + 100*i); 
     }
    

    It works well with JAVA. But I do not know why Android mode does not work. Is there anything I can do in Android mode?

  • Those slashes in the URL look to be the wrong way around to me. URLs always contain / rather than \ . you say it works in Java but maybe Java is a bit more tolerant of that stuff than android.

  • Answer ✓

    @Gwak===

    as for android - not for java- the OpenFileInput("") works only in this context and WITHOUT file separator (see line 2 &&3 of your error code) ; it seems that P5 loadStrings in android mode uses it.

    see also:

    https://developer.android.com/reference/android/content/Context.html#openFileInput(java.lang.String)

  • @akenaton , I guess you said it exactly. Dear akhenaten,

    import android.content.Context;
    

    How do I build the source code for the next step?

    Also, can you solve it? please reply.

  • Answer ✓

    @Gwak===

    not sure wether it works but, as for me, i would try to download (AsyncTask with an url connection && inputStream) the file to my storage directory in order that i can get access to it.

  • @akenaton

    Your words are correct. It seems to be the difference between Java mode and Android mode. To solve Android mode, I implemented it with (http: :) link.

      Thank you for your kind answer. Have a nice day.

Sign In or Register to comment.