diff options
Diffstat (limited to 'org.eclipse.osee.ote.core/src/org/eclipse/osee/ote/classserver/ResourceFinder.java')
-rw-r--r-- | org.eclipse.osee.ote.core/src/org/eclipse/osee/ote/classserver/ResourceFinder.java | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/org.eclipse.osee.ote.core/src/org/eclipse/osee/ote/classserver/ResourceFinder.java b/org.eclipse.osee.ote.core/src/org/eclipse/osee/ote/classserver/ResourceFinder.java new file mode 100644 index 000000000..ae6a68d4e --- /dev/null +++ b/org.eclipse.osee.ote.core/src/org/eclipse/osee/ote/classserver/ResourceFinder.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * 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: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.ote.classserver; + +import java.io.DataInputStream; +import java.io.IOException; +import java.io.InputStream; + +public abstract class ResourceFinder { + + public abstract byte[] find(String path) throws IOException; + + public byte[] getBytes(InputStream in, long length) throws IOException { + DataInputStream din = new DataInputStream(in); + byte[] bytes = new byte[(int) length]; + try { + din.readFully(bytes); + } finally { + din.close(); + } + return bytes; + } + + public byte[] getBytes(InputStream stream) throws IOException { + return getBytes(stream, stream.available()); + } + + public abstract void dispose(); +} |