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

Lahiru Prasanna
  • 1,012
  • 2
  • 15
  • 32

1 Answers1

1
import java.nio.charset.StandardCharsets;



byte[] view = "xxx".getBytes(StandardCharsets.UTF_8);
MuaazH
  • 152
  • 14