Reputation: 167
I want to write a JAVA program that can convert any file into binary form and store it into a text file.
And when another JAVA program that takes the above generated text file to regenerate the original file.
Here binary form refers to the the format of ones and zeros in which the data is stored in permanent memory like HDDs.
NOTE : I don't want a binary file that is not readable, I just want to see those 1 and 0 written in a text file.
Example :
I have a video like "hello.mkv" --> I give this file's path to program 1 --> It generates a file "output.txt" consisting of ones and zeros ---> I give this file's path to program 2 --> It gives back me the original file "hello.mkv".
I know it's weired and I am not sure whether it is possible or not.
Upvotes: 0
Views: 649
Reputation: 146
f = open('file1.mp3', 'rb')
file_content = f.read()
f.close()
This is how a file can be opened in binary mode in python, where b mentioned in the file open function specifies the files to be opened in binary mode. The above code is an example.
Upvotes: 0