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 getClass().getClassLoader().getResourceAsStream(path.substring(1));
34 throw new FileNotFoundException(path);
41 public OutputStream openOutputStream() throws IOException {
42 throw new UnsupportedOperationException("Read Only FileObject"); //NOI18N
46 public Reader openReader(boolean ignoreEncodingErrors) throws IOException {
47 return new InputStreamReader(openInputStream());
51 public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
52 final BufferedReader in = new BufferedReader(openReader(ignoreEncodingErrors));
54 final StringBuilder sb = new StringBuilder();
56 while ((line = in.readLine()) != null) {
58 sb.append('\n'); //NOI18N
67 public Writer openWriter() throws IOException {
68 return new OutputStreamWriter(openOutputStream());
72 public long getLastModified() {
73 return System.currentTimeMillis();
77 public boolean delete() {