Skip to content

Commit 180f0d9

Browse files
hansonrhansonr
authored andcommitted
printwriter fix -- no need for reflection
1 parent 9e373b1 commit 180f0d9

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

sources/net.sf.j2s.java.core/src/java/io/PrintWriter.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ public PrintWriter(OutputStream out, boolean autoFlush) {
173173
*/
174174
public PrintWriter(String fileName) throws FileNotFoundException {
175175
this(new BufferedWriter(new OutputStreamWriter(
176-
newFileOutputStream(new File(fileName)))), false);
176+
new FileOutputStream(new File(fileName)))), false);
177177
}
178178

179179
/**
@@ -211,13 +211,7 @@ public PrintWriter(String fileName) throws FileNotFoundException {
211211
public PrintWriter(String fileName, String csn) throws FileNotFoundException,
212212
UnsupportedEncodingException {
213213
this(new BufferedWriter(new OutputStreamWriter(
214-
newFileOutputStream(new File(fileName)), csn)), false);
215-
}
216-
217-
private static OutputStream newFileOutputStream(File file) {
218-
return (OutputStream) Interface.getInstanceWithParams(
219-
"java.io.FileOutputStream", new Class[] { java.io.File.class },
220-
new Object[] { file });
214+
new FileOutputStream(new File(fileName)), csn)), false);
221215
}
222216

223217
/**
@@ -248,7 +242,7 @@ private static OutputStream newFileOutputStream(File file) {
248242
* @since 1.5
249243
*/
250244
public PrintWriter(File file) throws FileNotFoundException {
251-
this(new BufferedWriter(new OutputStreamWriter(newFileOutputStream(file))),
245+
this(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file))),
252246
false);
253247
}
254248

@@ -287,7 +281,7 @@ public PrintWriter(File file) throws FileNotFoundException {
287281
*/
288282
public PrintWriter(File file, String csn) throws FileNotFoundException,
289283
UnsupportedEncodingException {
290-
this(new BufferedWriter(new OutputStreamWriter(newFileOutputStream(file),
284+
this(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file),
291285
csn)), false);
292286
}
293287

0 commit comments

Comments
 (0)