S
S
sendr2022-01-14 12:11:31
JavaScript
sendr, 2022-01-14 12:11:31

How to get the same file content in java that js returns?

Using the FileReader() and readAsDataURL(file) methods in javascript, I get the contents of a file like this
61e13d05d6624519321940.png

. In Java/android, I use a ByteArrayOutputStream and get similar content, but most of the characters are represented as placeholders �
61e13e01b8456710608477.png

Why is that? How to get the same string in Java as in js?
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Z
Zhbert, 2022-01-14
@Zhbert

You need to look in the same encoding in both cases.

A
Alexander Interesting, 2022-01-16
@Swimergg

Perhaps java receives exactly the same bytes, but different consoles display characters differently. Suppose in your screenshot in js the console replaces incomprehensible characters with spaces, and in the second console, that is, java, it is replaced with question marks

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question