• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ArrayIndexOutOfBoundException while reading the file

 
Pramod P Deore
Ranch Hand
Posts: 632
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello everybody, I am developing one application in that I am reading one file in parts (I am reading 102400 bytes at a time ) and sending it to server. size of file is more than 5mb. I had write following method to read the file


But when this method throws IndexOutOfboundException as



Actually I thought because of it reads from start to end and store it to byteArray, but it is not working like that.

Anybody knows what I am doing wrong?

Thanks

 
Ankit Garg
Sheriff
Posts: 9577
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a normal Java IO problem. I don't know why you are wrapping FileInputStream with DataInputStream if all that you have to do is read bytes. There is no need to maintain start and end either. You just can read 102400 bytes at a time using the read(byte[]) method. There is no need to call the skip method too. All that's needed is something like this
 
Pramod P Deore
Ranch Hand
Posts: 632
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ankit .It works fine.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic