Unfortunately we are not always able to provide precise code that covers every use case - you should use the documentation and the SDKs (and the advice given in this thread) to create a solution that is suitable. It looks like @abhishek_pyro has provided an example method you could make use of, but you’ll need to integrate that into your own code. The ton_upload tool should demonstrate the method for uploading to the TON API, and you can convert that into the right steps in Java.
We’d very much welcome contributions to our examples, if you are willing to share your solution with the community once you’ve built something that works for you.