Fixed ClassLoader problems.
2 * To change this license header, choose License Headers in Project Properties.
3 * To change this template file, choose Tools | Templates
4 * and open the template in the editor.
7 package org.apidesign.bck2brwsr.dew;
9 import java.io.BufferedReader;
10 import java.io.FileNotFoundException;
11 import java.io.IOException;
12 import java.io.InputStream;
13 import java.io.InputStreamReader;
14 import java.io.OutputStream;
15 import java.io.OutputStreamWriter;
16 import java.io.Reader;
17 import java.io.Writer;
21 * @author Tomas Zezula
23 class ClassLoaderJavaFileObject extends BaseFileObject {
25 ClassLoaderJavaFileObject(final String path) {
26 super(path, getKind(path));
30 public InputStream openInputStream() throws IOException {
31 final InputStream in = getClass().getClassLoader().getResourceAsStream(path.substring(1));
33 throw new FileNotFoundException(path);
39 public OutputStream openOutputStream() throws IOException {
40 throw new UnsupportedOperationException("Read Only FileObject"); //NOI18N
44 public Reader openReader(boolean ignoreEncodingErrors) throws IOException {
45 return new InputStreamReader(openInputStream());
49 public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
50 final BufferedReader in = new BufferedReader(openReader(ignoreEncodingErrors));
52 final StringBuilder sb = new StringBuilder();
54 while ((line = in.readLine()) != null) {
56 sb.append('\n'); //NOI18N
65 public Writer openWriter() throws IOException {
66 return new OutputStreamWriter(openOutputStream());
70 public long getLastModified() {
71 return System.currentTimeMillis();
75 public boolean delete() {