How to read text file (.txt) from URL?

I need is to load a text file from my web server.

1) Use `myWWW = WWW(url);` to fetch data from your server.

2) Parse the resulting string for the data segments you need. `myWWW.text`

You will probably need a couple of helper functions.

`wwwStr2Array()` converts a string you might get from your WWW fetch to an array. http://answers.unity3d.com/questions/33243/array-dump-to-string-for-send-via-www/33351#33351

You can use the same idea if your WWW returns a string like: `username=fred&password=flintstones` - you would just put it through the delimiter split in the above link again.

Once your values are in arrays, you can just manipulate them as you would usually.

You could also use uQuery:

uQuery.Get("http://url.to/file.txt", function(data, xhr) {
    Debug.Log(data); // Prints the text
});

/* WebTextFileChecker.cs
This checks the text in a text file on the web - believe it!
*/

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class WebTextFileChecker:MonoBehaviour
	{
	public void Start()
		{
		StartCoroutine(Check());
		}
	
	private IEnumerator Check()
		{
		WWW w = new WWW("http://yourserver.com/handyFile.txt");
		yield return w;
		if (w.error != null)
			{
			Debug.Log("Error .. " +w.error);
			// for example, often 'Error .. 404 Not Found'
			}
         else
         	{
         	Debug.Log("Found ... ==>" +w.text +"<==");
         	// don't forget to look in the 'bottom section'
         	// of Unity console to see the full text of
         	// multiline console messages.
         	}
         
		/* example code to separate all that text in to lines:
		longStringFromFile = w.text
		List<string> lines = new List<string>(
			longStringFromFile
			.Split(new string[] { "\r","

" },
StringSplitOptions.RemoveEmptyEntries) );
// remove comment lines…
lines = lines
.Where(line => !(line.StartsWith(“//”)
|| line.StartsWith(“#”)))
.ToList();
*/

		}
	}