-
-
Notifications
You must be signed in to change notification settings - Fork 271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reading a text file #840
Comments
I'm not sure which |
Thanks. I managed to get it working with The following code works as expected: var txt = org.apache.commons.io.IOUtils.toString(new URI("https://api.github.com/octocat"), "UTF-8"); , while the following fails: var txt = org.teavm.apachecommons.io.IOUtils.toString(new URI("https://api.github.com/octocat"), "UTF-8");
And both fails if the URI is local, such as TeaVM 0.9.0, Java 21. |
In case of Apache commons, TeaVM clearly provides you with explanations: some of the methods required by this library, aren't supported. TeaVM only emulates subset of Java class library, see table here: https://teavm.org/jcl-report/recent/jcl.html as a workarond, you can write your own function that takes InputStream from URL, reads all bytes from it and constructs a string base on these bytes.
Fetch is supported. There's no such thing as "supported" in case of interaction with JavaScript. You can call any JavaScript API you like, see https://teavm.org/docs/runtime/jso.html. TeaVM also comes with some ready-to-use JavaScript definitions. These include
What do you mean by "failing"? Do they report any exceptions or print anything to browser console? |
Maven passes, but this is printed in browser console:
|
The next time you send any stack trace from browser, please, make sure you compiled you application with disabled minification. In this case I suppose the problem is that |
I tried |
But anyways, yes it is a MalformedURL issue and providing the full path via |
Hi,
I'm trying to read a text file as a String inside the TeaVM app. Consider a data JSON for example. It sees neither
IOUtils.toString
notXMLHttpRequest
work, although they do fetch from remote hots. May I ask if there is a special location where the file should be? Currently, it is in the same path asindex.html
.Best
The text was updated successfully, but these errors were encountered: