while ((count= contentStream.read(readBuffer, 0, chunkSize)) > 0)
while ((count= contentStream.read(readBuffer, 0, chunkSize)) != -1)
	public void write(IFile resource, IPath destinationPath) throws CoreException {		ByteArrayOutputStream output= null;		BufferedInputStream contentStream= null;				try {			output= new ByteArrayOutputStream();			if (!resource.isLocal(IResource.DEPTH_ZERO)) {				String message= JarPackagerMessages.getFormattedString("JarWriter.error.fileNotAccessible", resource.getFullPath()); //$NON-NLS-1$				throw JarPackagerUtil.createCoreException(message, null);			}			contentStream= new BufferedInputStream(resource.getContents(false));			int chunkSize= 4096;			byte[] readBuffer= new byte[chunkSize];			int count;			while ((count= contentStream.read(readBuffer, 0, chunkSize)) > 0)				output.write(readBuffer, 0, count);		} catch (IOException ex) {			throw JarPackagerUtil.createCoreException(ex.getLocalizedMessage(), ex);		} finally {			try {				if (output != null)					output.close();				if (contentStream != null)					contentStream.close();			} catch (IOException ex) {				throw JarPackagerUtil.createCoreException(ex.getLocalizedMessage(), ex);			}		}		try {			IPath fileLocation= resource.getLocation();			long lastModified= System.currentTimeMillis();			if (fileLocation != null) {				File file= new File(fileLocation.toOSString());				if (file.exists())					lastModified= file.lastModified();			}			write(destinationPath, output.toByteArray(), lastModified);		} catch (IOException ex) {			// Ensure full path is visible			String message= null;			if (ex.getLocalizedMessage() != null)				message= JarPackagerMessages.getFormattedString("JarWriter.writeProblemWithMessage", resource.getFullPath(), ex.getLocalizedMessage()); //$NON-NLS-1$;			else				message= JarPackagerMessages.getFormattedString("JarWriter.writeProblem", resource.getFullPath()); //$NON-NLS-1$			throw JarPackagerUtil.createCoreException(message, ex);		}						}