-
Bug
-
Resolution: Fixed
-
P3
-
1.2.0
-
1.2fcs
-
sparc
-
solaris_2.5.1
-
Verified
Name: aaC67449 Date: 04/28/98
HTMLEditorKit.write(...,int pos, int len) ignores pos and len.
Javadoc says:"
public void write(Writer out,
Document doc,
int pos,
int len) throws IOException, BadLocationException
Write content from a document to the given stream in a format appropriate for this kind of
content handler.
Parameters:
out - The stream to write to
doc - The source for the write.
pos - The location in the document to fetch the content.
len - The amount to write out.
Throws:
IOException - on any I/O error
BadLocationException - if pos represents an invalid location within the document.
Overrides:
write in class DefaultEditorKit"
So, The example bellow must write only part of text ("Test 2"), but it writes full text.
------------------Example-----------------------------------
import java.awt.swing.text.html.*;
import java.awt.swing.text.*;
import java.io.*;
public class Test {
public static void main(String argv[]) {
String test="<!DOCTYPE HTML PUBLIC \"-//w3c//DTD html 3.2//EN\"><HTML><HEAD><TITLE>test</TITLE></HEAD><BODY><P> Test 1 Test 2 Test 3 </P></BODY></HTML>";
HTMLEditorKit c = new HTMLEditorKit();
try {
Document doc=c.createDefaultDocument();
c.read(new StringReader(test),doc,0);
c.write(System.out,doc,7,14); // Should write only "Test 2"
} catch(Exception e) {
e.printStackTrace();
}
}
}
-------------------Output------------------------------------
<html>
<head>
<title>test</title>
</head>
<body>
<p>Test 1 Test 2 Test 3</p>
</body>
</html>
======================================================================