I wish to load data located on a website at http://www.example.com/file.extension. The file will most likely be .txt, but if I could save the data as an array, maybe .csv, and load the data as array as that is what it will be used as on the application side. JSON had popped into my head, but I wouldn’t know how to use that website-side. How would you load this file from the internet?
I wish to load data located on a website at http://www.example.com/file.extension . The file
Share
The simplest way is probably URLConnection. There’s a nice Oracle example of how you can load the response from a remote URL into a string. Then you can parse the string in whatever way seems easiest.
URLConnection belongs to the java.net package, which appears to be the same in Android as in the standard Java API, so it’s pretty safe to use the Oracle documentation. However, to guarantee consistency with Android, you might also want to look at the Android documentation, which also provides a nice example.