X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.compressions%2Fsrc%2Forg%2Fsimantics%2Fcompressions%2Fimpl%2FChannels.java;h=2c015e57b384c4d91cf95865035423c74e02fe33;hb=7754cc9adc240214e9ea864dc5dfe0aaed43b818;hp=41c8ec8737fab7267aa5a2ec9971712e25b5d3e3;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.compressions/src/org/simantics/compressions/impl/Channels.java b/bundles/org.simantics.compressions/src/org/simantics/compressions/impl/Channels.java index 41c8ec873..2c015e57b 100644 --- a/bundles/org.simantics.compressions/src/org/simantics/compressions/impl/Channels.java +++ b/bundles/org.simantics.compressions/src/org/simantics/compressions/impl/Channels.java @@ -1,50 +1,50 @@ -/******************************************************************************* - * Copyright (c) 2007, 2011 Association for Decentralized Information Management - * in Industry THTH ry. - * 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 - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.compressions.impl; - -import java.io.IOException; -import java.io.InputStream; -import java.nio.ByteBuffer; -import java.nio.channels.ReadableByteChannel; - -/** - * @author Tuukka Lehtonen - */ -public class Channels { - - public static int read(ReadableByteChannel channel, ByteBuffer intoBuffer, int expectedBytes) throws IOException { - int read = 0; - while (read < expectedBytes) { - int ret = channel.read(intoBuffer); - if (ret < 0) - return read; // End-Of-Stream - read += ret; - } - return read; - } - - public static int read(ReadableByteChannel channel, ByteBuffer intoBuffer) throws IOException { - return read(channel, intoBuffer, intoBuffer.limit()); - } - - public static int readStream(InputStream stream, byte[] array, int expectedBytes) throws IOException { - int read = 0; - while (read < expectedBytes) { - int ret = stream.read(array, read, expectedBytes - read); - if (ret < 0) - return read; // End-Of-Stream - read += ret; - } - return read; - } - +/******************************************************************************* + * Copyright (c) 2007, 2011 Association for Decentralized Information Management + * in Industry THTH ry. + * 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 + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.compressions.impl; + +import java.io.IOException; +import java.io.InputStream; +import java.nio.ByteBuffer; +import java.nio.channels.ReadableByteChannel; + +/** + * @author Tuukka Lehtonen + */ +public class Channels { + + public static int read(ReadableByteChannel channel, ByteBuffer intoBuffer, int expectedBytes) throws IOException { + int read = 0; + while (read < expectedBytes) { + int ret = channel.read(intoBuffer); + if (ret < 0) + return read; // End-Of-Stream + read += ret; + } + return read; + } + + public static int read(ReadableByteChannel channel, ByteBuffer intoBuffer) throws IOException { + return read(channel, intoBuffer, intoBuffer.limit()); + } + + public static int readStream(InputStream stream, byte[] array, int expectedBytes) throws IOException { + int read = 0; + while (read < expectedBytes) { + int ret = stream.read(array, read, expectedBytes - read); + if (ret < 0) + return read; // End-Of-Stream + read += ret; + } + return read; + } + } \ No newline at end of file