Skip to content

Commit 3419363

Browse files
author
Andrey Turbanov
committed
8294361: Cleanup usages of StringBuffer in SQLOutputImpl
Reviewed-by: rriggs, lancea
1 parent 1abf971 commit 3419363

File tree

1 file changed

+21
-36
lines changed

1 file changed

+21
-36
lines changed

src/java.sql.rowset/share/classes/javax/sql/rowset/serial/SQLOutputImpl.java

Lines changed: 21 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -321,24 +321,20 @@ public void writeTimestamp(java.sql.Timestamp x) throws SQLException {
321321
* use by a <code>SQLData</code> object attempting to write the attribute
322322
* values of a UDT to the database.
323323
*/
324-
@SuppressWarnings("unchecked")
325324
public void writeCharacterStream(java.io.Reader x) throws SQLException {
326-
BufferedReader bufReader = new BufferedReader(x);
327-
try {
328-
int i;
329-
while( (i = bufReader.read()) != -1 ) {
325+
BufferedReader bufReader = new BufferedReader(x);
326+
try {
327+
int i;
328+
while ((i = bufReader.read()) != -1) {
330329
char ch = (char)i;
331-
StringBuffer strBuf = new StringBuffer();
332-
strBuf.append(ch);
333330

334-
String str = new String(strBuf);
335331
String strLine = bufReader.readLine();
336332

337-
writeString(str.concat(strLine));
338-
}
339-
} catch(IOException ioe) {
333+
writeString(ch + strLine);
334+
}
335+
} catch (IOException ioe) {
340336

341-
}
337+
}
342338
}
343339

344340
/**
@@ -351,23 +347,17 @@ public void writeCharacterStream(java.io.Reader x) throws SQLException {
351347
* use by a <code>SQLData</code> object attempting to write the attribute
352348
* values of a UDT to the database.
353349
*/
354-
@SuppressWarnings("unchecked")
355350
public void writeAsciiStream(java.io.InputStream x) throws SQLException {
356-
BufferedReader bufReader = new BufferedReader(new InputStreamReader(x));
357-
try {
358-
int i;
359-
while( (i=bufReader.read()) != -1 ) {
351+
BufferedReader bufReader = new BufferedReader(new InputStreamReader(x));
352+
try {
353+
int i;
354+
while ((i = bufReader.read()) != -1) {
360355
char ch = (char)i;
361356

362-
StringBuffer strBuf = new StringBuffer();
363-
strBuf.append(ch);
364-
365-
String str = new String(strBuf);
366357
String strLine = bufReader.readLine();
367-
368-
writeString(str.concat(strLine));
358+
writeString(ch + strLine);
369359
}
370-
}catch(IOException ioe) {
360+
} catch (IOException ioe) {
371361
throw new SQLException(ioe.getMessage());
372362
}
373363
}
@@ -381,23 +371,18 @@ public void writeAsciiStream(java.io.InputStream x) throws SQLException {
381371
* use by a <code>SQLData</code> object attempting to write the attribute
382372
* values of a UDT to the database.
383373
*/
384-
@SuppressWarnings("unchecked")
385374
public void writeBinaryStream(java.io.InputStream x) throws SQLException {
386-
BufferedReader bufReader = new BufferedReader(new InputStreamReader(x));
387-
try {
388-
int i;
389-
while( (i=bufReader.read()) != -1 ) {
375+
BufferedReader bufReader = new BufferedReader(new InputStreamReader(x));
376+
try {
377+
int i;
378+
while ((i = bufReader.read()) != -1) {
390379
char ch = (char)i;
391380

392-
StringBuffer strBuf = new StringBuffer();
393-
strBuf.append(ch);
394-
395-
String str = new String(strBuf);
396381
String strLine = bufReader.readLine();
397382

398-
writeString(str.concat(strLine));
399-
}
400-
} catch(IOException ioe) {
383+
writeString(ch + strLine);
384+
}
385+
} catch (IOException ioe) {
401386
throw new SQLException(ioe.getMessage());
402387
}
403388
}

0 commit comments

Comments
 (0)