I am copying data from one file to another file.
No you aren't. You are decrypting an input stream and writing the plaintext to an output stream.
It takes more time.
More time than what?
What's the reason?
Basically your tiny buffer size. Raise it to at least 8192 bytes: more if there continues to be a benefit.
int numRead = 0;
You don't need to initialize this variable.
byte[] buf = new byte[512];
See above. Change to at least 8192.
while ( ( numRead = in.read( buf ) ) >= 0 )
read(byte[]) can only return zero if buf.length is zero, which is a programming error you don't want to loop forever on. Change the condition to > 0.
catch ( java.io.IOException e ) { }
Never ignore an exception.
I am using operation as Encrypt/Decrypt a file. So that's the reason i am using the buffer size is 512 bytes.
No it isn't. There's nothing about encryption or decryption that requires a 512-byte buffer.
byte[] buf = new byte[1024];