Created
May 10, 2011 15:49
-
-
Save macdonst/964730 to your computer and use it in GitHub Desktop.
Read a file with new File API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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