- Where Developers Learn, Share, & Build Careers
I am trying to read an XML file out of a zip file. The related code is below:
ZipInputStream zis = new ZipInputStream (is); Zip Entry Entry = zis.getNextEntry (); While (entry = tap) {if (entry.getName (.) Equals ("plugin.xml")} {int size = (int) entry.getSize (); Byte [] bytes = new byte [size]; Int read = zis.read (byte, 0, size); System.out.println ("file size:" + size); System.out.println ("Read bytes:" + read); }} When doing this work, the output is as follows:
File size: 5224 Bytes Read: 5224
Never causes a situation where the input stream is less than the "read bytes" file size. In this situation, I have changed the text value of the XML property of the same file as above and received the following result:
File size: 5218 Read bytes: 5205 // reader quickly Closed! I can not see any patterns whose XML files will work and which does not. It seems completely random.
Does anyone come in any way like this before?
forgot to mention edit: , Java code that is embedded in an off-shelf app that I can not change . My problem is trying to understand why it will not accept my XML file in some cases.
Where does it say that InputStream.read () , or its Implementation or override, buffer buffs? Check Javadoc What is actually said is that read () indicates either return -1 EOS or reads at least one byte in buffer. You loop
Comments
Post a Comment