Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

334
Views
¿Cómo convertir una cadena en un InputStream en Kotlin?

tengo una cadena:

 var myString:String = "My String"

¿Cómo puedo convertirlo en un InputStream en Kotlin?

over 4 years ago · Hanz Gallego
2 answers
Answer question

0

val myString = "text" val targetStream: InputStream = ByteArrayInputStream(initialString.toByteArray())

Pst. Si copia algún código Java, por ejemplo:

 String myString = "text"; InputStream targetStream = new ByteArrayInputStream(myString.getBytes());

Android Studio aparecerá "El contenido del portapapeles parece ser código Java. ¿Quieres convertirlo a Kotlin?

over 4 years ago · Hanz Gallego Report

0

Kotlin tiene una extensión para que String convierta directamente.

 val inputStream: InputStream = myString.byteInputStream()

El argumento en byteInputStream está predeterminado en charset: Charset = Charsets.UTF_8 .

Puede mirar la extensión escribiéndola y luego cmd+clic en ella o en el package kotlin.io archivo IOStream.kt

Confiar en la versión de Java no está mal, sino usar una forma idiomática más kotlin cuando sea posible

over 4 years ago · Hanz Gallego Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!