Convert binary text into file

Can you give your use-case in more details?

Sounds like you’re trying to get the contents of the Content-Disposition HTTP header. You got no problems with File.write itself; that one looks to work fine for you.