How do I convert EBCDIC format to ASCII using Scala programming?
Asked
Active
Viewed 1,657 times
0
-
3What have you tried? What specifically are you stuck on? – patatahooligan Feb 05 '18 at 20:51
-
i can convert EBCDIC format to ASCII in Unix by this 'dd if=input_file of=output_file conv=ascii' but i want do same conversion in scala. – user9318470 Feb 05 '18 at 22:16
1 Answers
0
Something along the lines of
import java.nio.file._
val ebcdicBytes = Files.readAllBytes(Paths.get("/whereEver/myEbcdicFile"))
val asciiBytes = new String(ebcdicBytes, "Cp1047").getBytes("ASCII")
might work.

Andrey Tyukin
- 43,673
- 4
- 57
- 93
-
i can convert EBCDIC format to ASCII in Unix by this 'dd if=input_file of=output_file conv=ascii' but i want do same conversion in scala. – user9318470 Feb 05 '18 at 22:15
-
Ok. The above code converts ebcdic to ascii using Scala (at least it should: I didn't bother testing it on any ebcdic-encoded files). Does it answer your question? If not: is anything unclear? I mean, it's like 2 lines, everything is built-in already... – Andrey Tyukin Feb 05 '18 at 22:19
-
Good. It looks like you should have enough material for an [MCVE](https://stackoverflow.com/help/mcve) by now. It would be nice if you could somehow provide an example of the file for which the problem occurs. – Andrey Tyukin Feb 05 '18 at 22:51
-
i need to do same as this in scala https://stackoverflow.com/questions/20349491/converting-ebcdic-to-ascii-in-java – user9318470 Feb 06 '18 at 14:49