Debian Codegraph @

plugins/org.eclipse.emf.gwt.common/src/org/eclipse/emf/emul/java/io/ByteArrayInputStream.java

raw
1 /**
2 * Copyright (c) 2010 Ed Merks and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v2.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v20.html
7 *
8 * Contributors:
9 * Ed Merks - Initial API and implementation
10 */
11 package java.io;
12
13
14 import java.io.IOException;
15
16 public class ByteArrayInputStream extends InputStream
17 {
18 protected byte[] bytes;
19 protected int index;
20
21 public ByteArrayInputStream(byte [] bytes)
22 {
23 this.bytes = bytes;
24 }
25
26 @Override
27 public int read() throws IOException
28 {
29 if (index >= bytes.length)
30 {
31 return -1;
32 }
33 else
34 {
35 return bytes[index++] & 0xFF;
36 }
37 }
38 }