1 package org.simantics.scl.osgi.internal;
3 import java.io.IOException;
4 import java.io.InputStream;
6 import java.nio.charset.Charset;
7 import java.util.Arrays;
9 import org.osgi.framework.Bundle;
11 public class BundleDocumentationSource {
12 public static final Charset UTF8 = Charset.forName("UTF-8");
14 public final String documentationName;
15 public final Bundle bundle;
18 public BundleDocumentationSource(String documentationName, Bundle bundle,
20 this.documentationName = documentationName;
25 public String getText() {
27 InputStream stream = url.openStream();
29 byte[] buffer = new byte[1024];
32 int count = stream.read(buffer, pos, buffer.length-pos);
36 if(pos == buffer.length)
37 buffer = Arrays.copyOf(buffer, buffer.length*2);
39 return new String(buffer, 0, pos, UTF8);
43 } catch(IOException e) {