/* CompatUtils.java (c) 2010-2011 Edward Swartz All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html */ package ejs.base.utils; import java.io.EOFException; import java.io.IOException; import java.io.InputStream; /** Global settings for the emulator as a whole. * @author ejs */ public class CompatUtils { /** * Overcome egregious buggy surprising behavior in {@link InputStream#skip(long)} * @param in * @param nBytes * @throws IOException */ public static void skipFully(InputStream in, long nBytes) throws IOException { long remaining = nBytes; while (remaining > 0) { long skipped = in.skip(remaining); if (skipped == 0) throw new EOFException(); remaining -= skipped; } } }