Java Help!!!!!!!

This is a program i have written and it gives a Error when i run the code.
the command IDENTIFY is used to identify my progrm with the server following certain protocol rules.
the rules in detail could also be described

communicating with the server RULE:
Length - 2 bytes - {0,sum of all the datas in bytes}.
Command Code - 2 bytes {0,20}.
Data  - n bytes
protocol version number - (2 bytes) - {2,0}.
protocol version name - (String)
      length  - 2 bytes {0,6}.
      String .getBytes().

CheckSum - 2 bytes - {(byte)sum/256 ,(byte) sum%256}

//The IDENTIFY Command

long initTime = System.currentTimeMillis();

String protocol_Name = "Remote";
//byte[] identify = {0,10,0,20,2,0,0,0, 2,30};

byte[] identify = {0,16,0,20,2,0};
String PR_SName = "PRS2.0";

byte[] strarray = {0,(byte)PR_SName.length()};

//get the bytes for the string to be appended

byte[] prs = PR_SName.getBytes("UTF-8") ;

byte[] tmp1 = new byte[ strarray.length + prs.length ] ;

System.arraycopy( strarray, 0, tmp1, 0, strarray.length ) ;

System.arraycopy( prs, 0, tmp1, strarray.length, prs.length ) ;

strarray = tmp1 ;
//create a temp array the length we will need for the two arrays joined

byte[] tmp = new byte[ identify.length + strarray.length ] ;

//copy the original array into the start of our temp array

System.arraycopy( identify, 0, tmp, 0, identify.length ) ;

//copy the appended array into the end of our temp array
System.arraycopy( prs, 0, tmp, identify.length, strarray.length ) ;

//set the identify array to point to our newly created temp array
identify = tmp ;
int sum = 0;
for(int i = 0; i< identify.length; i++)
      sum += identify[i];
System.out.println("Sum of all the bytes =" + sum);
identify[identify.length - 2] = (byte)(sum / 256);

identify[identify.length - 1] = (byte)(sum % 256);
len = identify.length;
dos = new DataOutputStream(outstream);

length = instream.available();

System.out.println("Available bytes in IDENTIFY command =" + length);
dis = new DataInputStream(instream);
//BufferedReader br = new BufferedReader(new InputStreamReader(dis));
//BufferedInputStream bufferinput1 = new BufferedInputStream(instream);
for (int i=1; i<=length; i++)
               byte response = (byte);            
long timeTaken = System.currentTimeMillis()-initTime;
System.out.println("\n" + timeTaken + "Milli Seconds taken");
catch(InterruptedException e)
      System.err.println("Error =" + e);
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

zzynxSoftware engineerCommented:
>> This is a program i have written and it gives a Error when i run the code.
Maybe you can tell us what error exactly? (Stack trace)
Question is what is the error that it gives you?
ashok3sepAuthor Commented:
IO Exception Error
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Post the full stack trace and also the line it occurs.
zzynxSoftware engineerCommented:
The more info you give us the better we can help you.
>>IO Exception Error
At what line in your code?
Like girionis said, please provide the full stack

Other question: what is the variable "instream"?
The definition isn't available in the code you posted.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ashok3sepAuthor Commented:
Anyway guys i solved it myself

thanks for your help

With regards,

zzynxSoftware engineerCommented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.