-
Bug
-
Resolution: Fixed
-
P3
-
1.2.0
-
swing1.1
-
sparc
-
solaris_2.5
-
Verified
Name: akC57697 Date: 03/27/98
java.awt.swing.text.DefaultEditorKit.read(Reader in,Document doc,int pos)
ignores pos and appends a data to the Document.
Doc. says:
"
public void read(Reader in,
Document doc,
int pos) throws IOException, BadLocationException
Inserts content from the given stream, which will be treated as
plain text.
Parameters:
in - The stream to read from
doc - The destination for the insertion.
pos - The location in the document to place the content.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Throws:
IOException - on any I/O error
BadLocationException - if pos represents an invalid location
within the document.
Overrides:
read in class EditorKit
"
-----------------------Example--------------------
import java.awt.swing.text.*;
public class testDefaultKit {
public static void main(String s[]) {
String string = new String("string ");
java.io.StringReader reader = new java.io.StringReader(string);
DefaultEditorKit editor = new DefaultEditorKit();
Document doc = new PlainDocument();
try {
editor.read(reader,doc,0); // Insert at the begin of
// the document content
reader.reset();
System.out.println(doc.getText(0,doc.getLength()));
editor.read(reader,doc,0); // The length and the content
// must be the same.
reader.close();
System.out.println(doc.getText(0,doc.getLength())); // Only one
// string expected
} catch (Exception e) {
System.out.println("Unexpected in the reading : "+e);
return;
}
}
}
--------------------------------------------------
Output:
string
string string
======================================================================