This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 42638
Collapse All | Expand All

(-)src/org/netbeans/modules/java/source/parsing/SourceFileObject.java (-4 / +6 lines)
Lines 40-45 Link Here
40
import org.netbeans.api.java.lexer.JavaTokenId;
40
import org.netbeans.api.java.lexer.JavaTokenId;
41
import org.netbeans.modules.java.source.parsing.DocumentProvider;
41
import org.netbeans.modules.java.source.parsing.DocumentProvider;
42
import org.netbeans.api.lexer.TokenHierarchy;
42
import org.netbeans.api.lexer.TokenHierarchy;
43
import org.netbeans.api.queries.FileEncodingQuery;
43
import org.netbeans.modules.java.preprocessorbridge.spi.JavaFileFilterImplementation;
44
import org.netbeans.modules.java.preprocessorbridge.spi.JavaFileFilterImplementation;
44
import org.openide.ErrorManager;
45
import org.openide.ErrorManager;
45
import org.openide.cookies.EditorCookie;
46
import org.openide.cookies.EditorCookie;
Lines 124-130 Link Here
124
   
125
   
125
126
126
    public java.io.Writer openWriter() throws IOException {
127
    public java.io.Writer openWriter() throws IOException {
127
        return new OutputStreamWriter (this.openOutputStream(),FileObjects.encodingName);
128
        return new OutputStreamWriter (this.openOutputStream(), FileEncodingQuery.getEncoding(file));
128
    }
129
    }
129
130
130
    public Reader openReader(boolean ignoreEncodingErrors) throws IOException {        
131
    public Reader openReader(boolean ignoreEncodingErrors) throws IOException {        
Lines 138-144 Link Here
138
        else {
139
        else {
139
            final Document doc = getDocument(isOpened());
140
            final Document doc = getDocument(isOpened());
140
            if (doc == null) {
141
            if (doc == null) {
141
                Reader r = new InputStreamReader (this.file.getInputStream(),FileObjects.encodingName);
142
                Reader r = new InputStreamReader (this.file.getInputStream(),FileEncodingQuery.getEncoding(file));
142
                if (filter != null) {
143
                if (filter != null) {
143
                    r = filter.filterReader(r);
144
                    r = filter.filterReader(r);
144
                }
145
                }
Lines 470-482 Link Here
470
                        public void run () {
471
                        public void run () {
471
                            try {
472
                            try {
472
                                doc.remove(0,doc.getLength());
473
                                doc.remove(0,doc.getLength());
473
                                doc.insertString(0,new String(data,0,pos,FileObjects.encodingName),null);
474
                                //todo: use new String(data,0,pos,FileEncodingQuery.getEncoding(file)) on JDK 6.0
475
                                doc.insertString(0,new String(data,0,pos,FileEncodingQuery.getEncoding(file).name()),null);
474
                            } catch (BadLocationException e) {
476
                            } catch (BadLocationException e) {
475
                                ErrorManager.getDefault().notify(e);
477
                                ErrorManager.getDefault().notify(e);
476
                            }
478
                            }
477
                            catch (UnsupportedEncodingException ee) {
479
                            catch (UnsupportedEncodingException ee) {
478
                                ErrorManager.getDefault().notify (ee);
480
                                ErrorManager.getDefault().notify (ee);
479
                            }
481
                        }
480
                        }
482
                        }
481
                    });
483
                    });
482
            } finally {
484
            } finally {

Return to bug 42638