@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { int len = in.readInt(); byte[] b = new byte[len]; // read fully int done = 0; while (done < len) { int got = in.read(b, done, len - done); if (got < 0) throw new IOException(); done += got; } FileSystemProto.Directory proto = FileSystemProto.Directory.parseFrom(b); path = proto.getPath(); lastModified = proto.getLastModified(); List<FileSystemProto.File> files = proto.getFilesList(); children = new CacheFileProto[files.size()]; for (int i = 0; i < files.size(); i++) { FileSystemProto.File fp = files.get(i); CacheFileProto cf = new CacheFileProto(); cf.setShortName(fp.getName()); cf.setDirectory(fp.getIsDirectory()); cf.setLastModified(fp.getLastModified()); cf.setLength(fp.getLength()); children[i] = cf; } }