Skip to content

Instantly share code, notes, and snippets.

@macdonst
Created May 10, 2011 15:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save macdonst/964730 to your computer and use it in GitHub Desktop.
Save macdonst/964730 to your computer and use it in GitHub Desktop.
Read a file with new File API
function readArabic() {
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, getFS, fail);
}
function getFS(fileSystem) {
fileSystem.root.getFile("articals.txt", {"create":false, "exclusive":false}, gotArticals, fail);
}
function gotArticals(fileEntry) {
fileEntry.file(getFile, fail);
}
function getFile(articals) {
var reader = new FileReader();
reader.onloadend = function(evt) {
console.log("Read as text");
console.log(evt.target.result);
alert(evt.target.result.length);
};
reader.readAsText(articals);
}
function fail(error)
{
console.log(error.code);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment