This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
Firstly, I am sorry if the thread ( my post ) already exist,if so kindly refer me that post. I have searched already about my problem but i could not find solution.
Secondly, i describe about my problem here.
i have to read a image ( which is stored in binary format) from server ( php - xampp) . i am using Applet to read image (binary file) from server and i have to convert into original image then i have to take print out.
Thank you for your reply. A image file has been converted into binary ( for security purpose, image will not be sent directly to client(applet) so that image has been converted into binary format ). My applet will listen or by sending request, it will read binary image format file in stream and keep it in applet.
Then i have to convert this binary image file into ordinary .jpg file and take printout.
Hope i explained my problem clearly.
Could you please help me how to solve this problem....i am in need.
Thanks in advance.
With the above problem , first i started to convert the image into binary (1 | 0 ).
Could you please whether i am using correct way to change image to binary , if so please tell me what to do next to convert binary to ordinary image again.
Could you please UseCodeTags next time? It makes your code so much easier to read.
By reading it as an image, then storing it as an image again the quality of the image may become less. It's probably better to open a connection to the URL and copy the bytes into the ByteArrayOutputStream directly:
I sugges you give your file a different extension. "bat" is used for Windows / DOS batch scripts. "dat" is much more common for binary data files.
This is where you're logic goes wrong. The binary file will contain only 0 and 1 bytes. That's right, bytes. You've essentially made your file up to 8 times as big, as now it uses 1 byte for each bit (ignoring leading zeros).
Usually I'd say to use the original file directly, but you don't want to do this because of security concerns. That means that you have to encrypt the file, then decrypt the file again before you convert the file back to an image. You have a crude way of encrypting, but you don't decrypt it back.
Now you use your own, very simplistic encryption. I would take a look at CipherOutputStream and CipherInputStream instead, with a secure encryption algorithm like AES or Blowfish. The advantage is that it adds even more security (you need a key to decrypt), but it also doesn't make your file up to 8 times as big.
If you still want to use your own encryption technique, you should improve it. Make sure that each byte is stored in 8 bytes, not make it dependent on the value. So do not use Integer.toBinaryString(by) but use bit-wise operations:
The decrypting, using a DataInputStream wrapped around the InputStream so you can use the readFully method:
Joined: Jun 08, 2011
Is this code right?(i am new to java ) . It shows error that java.io.EOFException at last, and in generated bin file, there are nul values. what would be the problem