Okay, for devs facing similar issues. I figured out the answer.
Salut works well with LoganSquare except that it needs data to be serialized to send to other devices. To send files, we can contain them in a seralizable class as a String field of the class as Strings are serializable.
HOW TO DO THAT?
- Load the file in FileOutputStream
- Convert it to ByteArrayOutputStream
- Then convert it to String
BUT I HAVE A HUGE file! How much would the capacity of the String be?
No worries!
String can store up to (2^31)-1 characters (Integer.MAX_VALUE)
Calculations -
- (2^31)-1 = 2,147,483,648 characters
- Assuming Java takes 2 bytes for a character :
2,147,483,648 characters = 2,147,483,648/2 = 1,073,741,824 bytes = 1,048,576 KB = 1024 MB = 1 GB
(or simple 1KB = 2^10 bytes , 1MB = 2^20 bytes, 1GB = 2^30 bytes )
Are you going to send a file more than 1 GB size ?
If yes, you can use a String[ ].
Problems on security ?
You can encrypt the file before sending !