0

What is the equivalent java function of encoder.encode . I want to convert following JavaScript funtion to java .

function fun(){
const encoder = new TextEncoder()
const view = encoder.encode('xxx').buffer
console.log(view); 

}

but the thing is couldn't find any equivalent code to get similar result

0

1 Answer 1

1
import java.nio.charset.StandardCharsets;



byte[] view = "xxx".getBytes(StandardCharsets.UTF_8);
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.