Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem in reading bytes

Chennarao Marvatu
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi friends ,How are you all
My task is ..I am sending the file to the server from the client
i want to send the file some parts of bytes ...That is suppose
my file is 470 bytes i want to send with 100 100 100 100 like this
i want to send it ..i have written the code but getting exception
after reading the 400 byte what is the problem

please send me the code for this very urgent


FileInputStream in = new FileInputStream(new File("E:/Medplexus-EMR/AutoUpdate/Medplexus.ini"));
while((!= -1){

serverData = serverData + String.valueOf((char)i);


dataInByte = serverData.getBytes();
int len = dataInByte.length;
System.out.println("Length ==="+len);
byteNo = len/100;
exBytes = len%100;

nextVal = len;
System.out.println("100's ==="+byteNo);
System.out.println("ExBytes ==="+exBytes);

outputS = new DataOutputStream(socket.getOutputStream());


for (i=0 ; i<=(dataInByte.length-exBytes); i++){

System.out.println("======k "+k);

if((i%100)==0 && i!=0) {
System.out.println("======in If condition ");
System.out.println("K value "+k);
System.out.println("Sent 100 Bytes i "+i);
System.out.println(" dataInByte.length "+dataInByte.length);

k = i;

System.out.println("K====== at Ex Bytes"+k);

this is my client code
Joe Ess
Posts: 9323
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Chennarao Marvatu:

please send me the code for this very urgent

Everyone's question is urgent. Posting a big block of code and asking for a fix is an almost certain way to have your question ignored. To get your question answered you must recognize that we are all volunteers here, and anything you can do to make our job easier will make your question more likely to be answered. For example, use the UUB code (when you type your message in, there's a bunch of buttons under the text box). The "Code" tag will preserve the format of your code making it easier to read. Comment your code, or at least separate the client and server code. Include the stack trace of any exception and indicate where in the code it occurs.
As it is, you would be best off taking a look at the Java Tutorial: Using IO Streams Tutorial for some examples of how to use streams effectively.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic