CharlesO
I’ve built and Elixir application that needs to read files produced by a Legacy Java platform.
Looking at the Java source shows clearly how the files are being constructed:
HashMap localHashMap = null;
List localList1 = null;
...
ByteArrayOutputStream localByteArrayOutputStream = null;
ObjectOutputStream localObjectOutputStream = null;
localByteArrayOutputStream = new ByteArrayOutputStream();
localObjectOutputStream = new ObjectOutputStream(localByteArrayOutputStream);
localObjectOutputStream.flush();
localHashMap = new HashMap();
localHashMap.put("SecretKey", someBytes);
localHashMap.put("EncryptedData", localList1);
localHashMap.put("IVSpec", someMoreBytes);
localObjectOutputStream.writeObject(localHashMap);
arrayOfByte3 = localByteArrayOutputStream.toByteArray();
At the end of the day it’s really just a Java HashMap with known string keys that’s being written to file…
I tried to grok this link below, but i feel there’s got to be a much simpler way to interop common data structures from other platforms
https://medium.com/@mr.anmolsehgal/java-hashmap-internal-implementation-21597e1efec3
Any suggestions please?
Samples:
http://paperlesssolutionsltd.com.ng/sample1.zip
http://paperlesssolutionsltd.com.ng/sample2.zip
Trending in Questions
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
Hello,
I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind.
However, when I launch mix phx.server, I get an error...
New
Hi everyone.
My team and I have been working on a fairly modest app based around video streaming and chat, but we’ve landed a customer t...
New
I really like the adapter patterns that ecto, nebulex, waffle, etc. use and would love find something similar for a key management servic...
New
Hello folks!
So at work, we are seeing some situations where we have to define some “fixed” strings that are used across the codebase in...
New
I’m working on a small exercise involving update_in/3, and I came up with this solution:
data = %{
name: "Periodic Table",
category:...
New
How Can I Optimise Compile Time Dependencies
I have been building an elixir application for about 2 years now. Many modules and files ha...
New
Other Trending Topics
ReqLLM v1.28.0 has been released.
Features:
add StepFun chat and audio providers (#1087) by mikehostetler
openai: honour image deta...
New
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
A little off-topic, but I feel like people here have a good head on their shoulders.
I used to be quite good at making software. Was luc...
New
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #ai
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixirconf-us
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #security
- #metaprogramming










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
benwilson512
Hey @CharlesO, your file.io links do not work for me, I get a 404 for both.
To make sure I understand what you’re trying to do, you’re trying to read these files in Elixir and build maps out of them?
CharlesO
sorry, i’ve moved them to my personal server:
http://paperlesssolutionsltd.com.ng/sample1.zip
http://paperlesssolutionsltd.com.ng/sample2.zip
CharlesO
I want to read the content into elixir.
Looking @ the Java source, it’s clear how they are being constructed.
benwilson512
@CharlesO Unzipping those files turns into
sample1.zip.cpgz, it does not unzip.Sure, but it isn’t clear at all what the format of the files are. The java source has nothing to do with the structure of the file.
CharlesO
Oh, those zip files were encrypted.
Decrypting them is not the problem, it is reading the Java Hashmap that’s the issues.
The Java source shows how the file was constructed … if i can read back the parts, I can easily decrypt the files. I have the keys and all.
benwilson512
What does a java hashmap written to a file look like? What is its format?
tcoopman
Wouldn’t it be easier to read them back in a java application and save them as json or an other interop format?
There is no magical solution to read files from an internal java binary format. You could always try to understand and parse the java binary format but that sounds like something that will be a lot of work and possible error prone.
CharlesO
That’s my question exactly. See what the code is doing:
It reads the zipped file, encrypts it, and overwrites the same zipped file name with the encrypted content.
basically this: https://paperlesssolutionsltd.com.ng/RSASecImpl.java.txt
CharlesO
But once Java has written the bits to a physical - binary file, shouldn’t any programing language be able to readback the binary content?
tcoopman
Sure, every language can read it the physical bits, but how do you know what these bits represent? But I guess (because you didn’t specify in your original question) that you need to do something with the files in Elixir, so how do you know what the contents of the file mean?
The information on how the bits are stored are defined by the
ObjectOutputStreamfrom java. If you want to read them, you can, and you will have to parse them yourself. Basically implementing anObjectInputStreamin elixir.So, it would be a lot easier if instead of using the
ObjectOutputStreamyou wrote the files to ajsonorxmlformat in java. Then you don’t have to implement the binary parsing yourself.