I'm copying the code and the output as well I want to know why is it taking so much time to execute the program when provide larger data file as input.
Please see through out the code and give me suggestions and try to execute.
java Program:
FileInputStream fis = new FileInputStream("rose.jpg"); //use your own binary file name
DataInputStream dis = new DataInputStream(fis);
try {
byte buffer[] = new byte[16];
while((line = dis.read(buffer)) != -1)
{
for(int i = 0; i < line; i++)
{
value = Integer.toHexString(0xFF & buffer[i] | 0x100).substring(1);
nextvalue = nextvalue+""+value;
}
if(a == 0)
{
incValue = nextvalue.substring(0, 32);
System.out.println(incValue);
}
else
{
counter = counter + 32;
incValue = nextvalue.substring(counter, counter + 32);
System.out.println(incValue);
}
a++;
output:
ffd8ffe000104a464946000101020025
00250000ffdb00430002010101010102
01010102020202020403020202020504
04030406050606060506060607090806
0709070606080b08090a0a0a0a0a0608
0b0c0b0a0c090a0a0affdb0043010202
02020202050303050a0706070a0a0a0a
0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a
each line of the output will have 16 bytes of values.
Please, help me with this program what I have to modify and change so that program executes quickly.