當前位置: 首頁>>代碼示例>>Java>>正文


Java EditorKit.read方法代碼示例

本文整理匯總了Java中javax.swing.text.EditorKit.read方法的典型用法代碼示例。如果您正苦於以下問題:Java EditorKit.read方法的具體用法?Java EditorKit.read怎麽用?Java EditorKit.read使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.text.EditorKit的用法示例。


在下文中一共展示了EditorKit.read方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: loadFromStreamToKit

import javax.swing.text.EditorKit; //導入方法依賴的package包/類
@Override
protected void loadFromStreamToKit(StyledDocument doc, InputStream stream, EditorKit kit) throws IOException, BadLocationException {
    if (guardedEditor == null) {
        guardedEditor = new FormGEditor();
        GuardedSectionsFactory gFactory = GuardedSectionsFactory.find("text/x-java");
        if (gFactory != null) {
            guardedProvider = gFactory.create(guardedEditor);
        }
    }

    if (guardedProvider != null) {
        guardedEditor.doc = doc;
        Charset c = FileEncodingQuery.getEncoding(this.getDataObject().getPrimaryFile());
        Reader reader = guardedProvider.createGuardedReader(stream, c);
        try {
            kit.read(reader, doc, 0);
        } finally {
            reader.close();
        }
    } else {
        super.loadFromStreamToKit(doc, stream, kit);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:24,代碼來源:GuardedBlockTest.java

示例2: loadFromStreamToKit

import javax.swing.text.EditorKit; //導入方法依賴的package包/類
@Override
protected void loadFromStreamToKit(StyledDocument doc, InputStream stream, EditorKit kit)
        throws IOException, BadLocationException {
    
    if (guardedEditor == null) {
        guardedEditor = new BIGES();
        GuardedSectionsFactory gFactory = GuardedSectionsFactory.find(((DataEditorSupport.Env) env).getMimeType());
        if (gFactory != null) {
            guardedProvider = gFactory.create(guardedEditor);
        }
    }
    
    if (guardedProvider != null) {
        guardedEditor.doc = doc;
        Charset c = FileEncodingQuery.getEncoding(this.getDataObject().getPrimaryFile());
        Reader reader = guardedProvider.createGuardedReader(stream, c);
        try {
            kit.read(reader, doc, 0);
        } finally {
            reader.close();
        }
    } else {
        super.loadFromStreamToKit(doc, stream, kit);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:26,代碼來源:BIEditorSupport.java

示例3: loadFromStreamToKit

import javax.swing.text.EditorKit; //導入方法依賴的package包/類
@Override
protected void loadFromStreamToKit(StyledDocument doc, InputStream stream, EditorKit kit) throws IOException, BadLocationException {
    if (guardedEditor == null) {
        guardedEditor = new FormGEditor();
        GuardedSectionsFactory gFactory = GuardedSectionsFactory.find(((DataEditorSupport.Env) env).getMimeType());
        if (gFactory != null) {
            guardedProvider = gFactory.create(guardedEditor);
        }
    }
    
    if (guardedProvider != null) {
        guardedEditor.doc = doc;
        Charset c = FileEncodingQuery.getEncoding(this.getDataObject().getPrimaryFile());
        Reader reader = guardedProvider.createGuardedReader(stream, c);
        try {
            kit.read(reader, doc, 0);
        } finally {
            reader.close();
        }
    } else {
        super.loadFromStreamToKit(doc, stream, kit);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:24,代碼來源:FormEditorSupport.java

示例4: loadFromStreamToKit

import javax.swing.text.EditorKit; //導入方法依賴的package包/類
/**
 * Reads the file from the stream, filter the guarded section
 * comments, and mark the sections in the editor. Overrides superclass method. 
 * @param document the document to read into
 * @param inputStream the open stream to read from
 * @param editorKit the associated editor kit
 * @throws <code>IOException</code> if there was a problem reading the file
 * @throws <code>BadLocationException</code> should not normally be thrown
 * @see #saveFromKitToStream
 */
@Override
protected void loadFromStreamToKit(StyledDocument document, InputStream inputStream, EditorKit editorKit) throws IOException, BadLocationException {
    final Charset c = getCharset();
    final Reader reader = new BufferedReader(new InputStreamReader(inputStream, c));

    try {
        editorKit.read(reader, document, 0);
    } finally {
        reader.close();
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:22,代碼來源:PropertiesEditorSupport.java

示例5: rtf2html

import javax.swing.text.EditorKit; //導入方法依賴的package包/類
public String rtf2html(final String rtf) {
	final JEditorPane p = new JEditorPane();
	p.setContentType("text/rtf");
	final EditorKit kitRtf = p.getEditorKitForContentType("text/rtf");
	try {
		kitRtf.read(new StringReader(rtf), p.getDocument(), 0);
		final Writer writer = new StringWriter();
		final EditorKit editorKitForContentType = p.getEditorKitForContentType("text/html");
		editorKitForContentType.write(writer, p.getDocument(), 0, p.getDocument().getLength());
		return writer.toString();
	} catch (IOException | BadLocationException e) {
		throw new RTF2HTMLException("Could not convert RTF to HTML.", e);
	}
}
 
開發者ID:TheConfusedCat,項目名稱:msgparser,代碼行數:15,代碼來源:JEditorPaneRTF2HTMLConverter.java

示例6: loadFromStreamToKit

import javax.swing.text.EditorKit; //導入方法依賴的package包/類
protected void loadFromStreamToKit(StyledDocument doc, InputStream stream, EditorKit kit)
throws IOException, BadLocationException {
    Editor.this.doc = doc;
    kit.read(stream, doc, 0);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:6,代碼來源:Editor.java

示例7: loadFromStreamToKit

import javax.swing.text.EditorKit; //導入方法依賴的package包/類
@Override
protected void loadFromStreamToKit(StyledDocument doc, InputStream stream, EditorKit kit) throws IOException, BadLocationException {
    kit.read(new InputStreamReader(stream, charset), doc, 0);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:5,代碼來源:Utils.java

示例8: loadFromStreamToKit

import javax.swing.text.EditorKit; //導入方法依賴的package包/類
protected void loadFromStreamToKit(StyledDocument doc, InputStream stream, EditorKit kit)
throws IOException, BadLocationException {
    kit.read(new InputStreamReader(stream, dObj.getEncodingHelper().getEncoding()), doc, 0);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:5,代碼來源:XmlMultiViewEditorSupport.java

示例9: getReaderFromKit

import javax.swing.text.EditorKit; //導入方法依賴的package包/類
/** @return The reader or <code>null</code>. */
private Reader getReaderFromKit(File file, FileObject fo, String mimeType) throws FileNotFoundException {
    EditorKit kit = CloneableEditorSupport.getEditorKit(mimeType);
    if (kit.getContentType().equalsIgnoreCase("text/plain") && "text/x-dtd".equalsIgnoreCase(mimeType)) {
         // Use XML kit for DTDs if not defined otherwise
        kit = CloneableEditorSupport.getEditorKit("text/xml");
    }
    //System.out.println("  KIT for "+mimeType+" = "+kit);
    if (kit != null) {
        Document doc = kit.createDefaultDocument();
        InputStream stream = null;
        try {
            if (file != null) {
                stream = new FileInputStream(file);
            } else {
                stream = fo.getInputStream();
            }
            kit.read(stream, doc, 0);
            String text = doc.getText(0, doc.getLength());
            //System.out.println("  TEXT = "+text);
            doc = null; // Release it, we have the text
            return new StringReader(text);
        } catch (IOException ioex) {
            FileNotFoundException fnfex;
            if (file != null) {
                fnfex = new FileNotFoundException("Can not read file "+file.getAbsolutePath());
            } else {
                fnfex = new FileNotFoundException("Can not read file "+fo);
            }
            fnfex.initCause(ioex);
            throw fnfex;
        } catch (BadLocationException blex) { // Something wrong???
            ErrorManager.getDefault().notify(blex);
        } finally {
            if (stream != null) {
                try { stream.close(); } catch (IOException e) {}
            }
        }
    }
    return null;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:42,代碼來源:EncodedReaderFactory.java


注:本文中的javax.swing.text.EditorKit.read方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。