How to write Java String # getBytes in Kotlin?

In Kotlin you can do the same with a function called toByteArray. Default values are provided for charset, and Charsets.UTF_8 is used if not specified in the argument.

val foo = "foo"
foo.toByteArray()

https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/to-byte-array.html

Recommended Posts

How to write Java String # getBytes in Kotlin?
[Rails] How to write in Japanese
How to learn JAVA in 7 days
How to use classes in Java?
How to name variables in Java
How to concatenate strings in java
How to store a string from ArrayList to String in Java (Personal)
How to implement date calculation in Java
How to implement Kalman filter in Java
Multilingual Locale in Java How to use Locale
How to do base conversion in Java
[Introduction to Java] How to write a Java program
[Java] How to output and write files!
How to output Java string to console screen
How to implement coding conventions in Java
How to embed Janus Graph in Java
How to get the date in java
[JavaFX] How to write Eclipse permissions in build.gradle
How to write Rails
Java Development Basics ~ How to Write Programs * Exercise 1 ~
How to display a web page in Java
Code to escape a JSON string in Java
JUnit 5: How to write test cases in enum
How to write dockerfile
How to hide null fields in response in Java
How to write docker-compose
How to write Mockito
[Java] How to substitute Model Mapper in Jackson
How to solve an Expression Problem in Java
[Java] Memo on how to write the source
Notes on how to write comments in English
Javaer tries to summarize how to write properties in C #
How to call functions in bulk with Java reflection
How to create a Java environment in just 3 seconds
[Java] How to omit the private constructor in Lombok
[Ruby on Rails] How to write enum in Japanese
How to write Scala from the perspective of Java
[Java] Types of comments and how to write them
How to input / output IBM mainframe files in Java?
java: How to write a generic type list [Note]
Write a class in Kotlin and call it in Java
How to create a data URI (base64) in Java
How to write a date comparison search in Rails
[Java] How to cut out a character string character by character
[Java] How to erase a specific character from a character string
How to convert A to a and a to A using AND and OR in Java
How to convert a file to a byte array in Java
How to Git manage Java EE projects in Eclipse
How to write an external reference key in FactoryBot
Summary of how to implement default arguments in Java
How to write modern Java. Immutable Java, consider Null safety.
How to put old Java (8 series) in macOS 10.15 Catalina
How to write a core mod in Minecraft Forge 1.15.2
Notes on how to use regular expressions in Java
[Java] How to use Map
How to lower java version
[Java] How to use Map
How to uninstall Java 8 (Mac)
How to write good code
Java --How to make JTable
How to use java Optional