package jetbrains.mps.core.tool.environment.classloading; /*Generated by MPS */ import java.net.URL; import java.io.InputStream; import java.io.IOException; import java.io.ByteArrayOutputStream; /*package*/ abstract class Resource { /*package*/ abstract URL getURL(); protected abstract InputStream getInputStream() throws IOException; protected abstract int getContentLength() throws IOException; /*package*/ byte[] getBytes() throws IOException { InputStream in = getInputStream(); if (in == null) { throw new IOException("No stream"); } int size = getContentLength(); byte[] buffer = new byte[8192]; ByteArrayOutputStream out = new ByteArrayOutputStream((size > 0 ? size : buffer.length)); int count; while ((count = in.read(buffer)) >= 0) { out.write(buffer, 0, count); } out.flush(); in.close(); return out.toByteArray(); } }