0

I would convert a FileInputStream to Array[Byte] in Scala 2.13 without using Apache Commons IO. How can I do that?

3
  • 1
    Does this answer your question? Convert InputStream to byte array in Java Commented Jul 6, 2020 at 15:20
  • I guess you could make it a string and then do getBytes on it? I've personally had this same issue some days ago and I juset went with Apache Commions IO solution. val byteArray = org.apache.commons.io.IOUtils.toByteArray(inputFiles) , why do you not wanna use that? Commented Jul 6, 2020 at 15:33
  • This also might work? val bis = new BufferedInputStream(new FileInputStream(fileName)) val bArray = Stream.continually(bis.read).takeWhile(-1 !=).map(_.toByte).toArray taken from: stackoverflow.com/questions/7598135/… Commented Jul 6, 2020 at 15:36

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.