Loading...
Logo
Processing Forum
hi.
i am trying to access a .txt file which is not present in the data folder of my sketch. can i do it in the first place? and if yes, how do i do it? please help me.

Replies(5)

please help me asap.
regards
priyankapardesi,

No need to revive old threads, hijack other people's threads or urge us to help you asap.

Instead you could have and should have tried it yourself. Then you would have seen it's possible and very simple.

Code Example
Copy code
  1. void setup() {
  2.   String[] strings = loadStrings("c:/someDirectory/someFile.txt");
  3.   println(strings);
  4. }
Why do you need to?

If you're trying to run your sketch on your own computer, simple move the text files you want to have it read to the data folder. Or point loadStrings() at the whole path to the file, as amon.owed has demonstrated above.

If you're trying to run the sketch on your local computer but want to read the text files from a URL, that is possible, simply give the URL to loadStrings().

If you're trying to get your program to run in a browser, it can read files from the same server that the sketch is hosted on.
If you want a sketch running in a browser to read a text file from the the user's local machine, or you want to read a text file from a different site, you may have to sign your applet (which is a pain in the butt to do and may make a lot of people not want to run your applet).
You asked the same question in another thread (unrelated to the question), so I lost my time (not much, admittedly) answering there while you were answered here. Avoid duplicate threads.
You ask a question, so why have you changed the topic type? (I restore it to Question).
And as said, no need to bump up a topic in the same hour than the first post.

I am not lecturing you, just giving some useful rules to follow in any forum.