You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by ju...@apache.org on 2001/02/01 18:16:27 UTC
cvs commit: jakarta-slide/src/share/org/apache/slide/content NodeRevisionContent.java
juergen 01/02/01 09:16:27
Modified: src/share/org/apache/slide/content NodeRevisionContent.java
Log:
The method readFromStream now may throw a IOException. Thanks for this hint Martin Gronberg [martyg@everest.com].
Revision Changes Path
1.7 +30 -30 jakarta-slide/src/share/org/apache/slide/content/NodeRevisionContent.java
Index: NodeRevisionContent.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/content/NodeRevisionContent.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- NodeRevisionContent.java 2001/01/29 10:29:37 1.6
+++ NodeRevisionContent.java 2001/02/01 17:16:25 1.7
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/content/NodeRevisionContent.java,v 1.6 2001/01/29 10:29:37 juergen Exp $
- * $Revision: 1.6 $
- * $Date: 2001/01/29 10:29:37 $
+ * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/content/NodeRevisionContent.java,v 1.7 2001/02/01 17:16:25 juergen Exp $
+ * $Revision: 1.7 $
+ * $Date: 2001/02/01 17:16:25 $
*
* ====================================================================
*
@@ -75,7 +75,7 @@
*
* @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
* @author Juergen Pill
- * @version $Revision: 1.6 $
+ * @version $Revision: 1.7 $
*/
public final class NodeRevisionContent implements Serializable {
@@ -123,13 +123,21 @@
reader = null;
};
if (inputStream != null) {
- content = new String(readFromStream(inputStream)).toCharArray();
+ try {
+ content = new String(readFromStream(inputStream)).toCharArray();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
result = content;
inputStream = null;
reader = null;
}
if (reader != null) {
- content = readFromReader(reader);
+ try {
+ content = readFromReader(reader);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
result = content;
inputStream = null;
reader = null;
@@ -245,7 +253,7 @@
* Read the data from the stream and return the result in a byte array.
* Return null in case of an error.
*/
- public static byte[] readFromStream(InputStream inputStream) {
+ public static byte[] readFromStream(InputStream inputStream) throws IOException {
byte[] chunk;
byte[] all;
int chunkLen;
@@ -256,19 +264,15 @@
int ofs;
allLen = 0;
- try {
+ chunk = new byte[CHUNK];
+ chunkLen = inputStream.read(chunk);
+ chunks = new ArrayList();
+ while (chunkLen != -1) {
+ chunks.add(new Integer(chunkLen));
+ chunks.add(chunk);
+ allLen += chunkLen;
chunk = new byte[CHUNK];
chunkLen = inputStream.read(chunk);
- chunks = new ArrayList();
- while (chunkLen != -1) {
- chunks.add(new Integer(chunkLen));
- chunks.add(chunk);
- allLen += chunkLen;
- chunk = new byte[CHUNK];
- chunkLen = inputStream.read(chunk);
- }
- } catch (IOException e) {
- return null;
}
all = new byte[allLen];
@@ -290,7 +294,7 @@
* Read the data from the reader and return the result in a char array.
* Return null in case of an error.
*/
- private char[] readFromReader(Reader reader) {
+ private char[] readFromReader(Reader reader) throws IOException {
char[] chunk;
char[] all;
int chunkLen;
@@ -301,19 +305,15 @@
int ofs;
allLen = 0;
- try {
+ chunk = new char[CHUNK];
+ chunkLen = reader.read(chunk);
+ chunks = new ArrayList();
+ while (chunkLen != -1) {
+ chunks.add(new Integer(chunkLen));
+ chunks.add(chunk);
+ allLen += chunkLen;
chunk = new char[CHUNK];
chunkLen = reader.read(chunk);
- chunks = new ArrayList();
- while (chunkLen != -1) {
- chunks.add(new Integer(chunkLen));
- chunks.add(chunk);
- allLen += chunkLen;
- chunk = new char[CHUNK];
- chunkLen = reader.read(chunk);
- }
- } catch (IOException e) {
- return null;
}
all = new char[allLen];