diff --git a/src/main/java/dan200/computercraft/core/apis/handles/EncodedInputHandle.java b/src/main/java/dan200/computercraft/core/apis/handles/EncodedInputHandle.java index 09c4cd498..1cc5141a1 100644 --- a/src/main/java/dan200/computercraft/core/apis/handles/EncodedInputHandle.java +++ b/src/main/java/dan200/computercraft/core/apis/handles/EncodedInputHandle.java @@ -23,7 +23,11 @@ public class EncodedInputHandle extends HandleGeneric public EncodedInputHandle( InputStream stream, String encoding ) { - super( stream ); + this( makeReader( stream, encoding ) ); + } + + private static BufferedReader makeReader( InputStream stream, String encoding ) + { if( encoding == null ) encoding = "UTF-8"; InputStreamReader streamReader; try @@ -34,7 +38,7 @@ public class EncodedInputHandle extends HandleGeneric { streamReader = new InputStreamReader( stream ); } - this.m_reader = new BufferedReader( streamReader ); + return new BufferedReader( streamReader ); } @Nonnull diff --git a/src/main/java/dan200/computercraft/core/apis/handles/EncodedOutputHandle.java b/src/main/java/dan200/computercraft/core/apis/handles/EncodedOutputHandle.java index 61db07fa4..89eb6dd2f 100644 --- a/src/main/java/dan200/computercraft/core/apis/handles/EncodedOutputHandle.java +++ b/src/main/java/dan200/computercraft/core/apis/handles/EncodedOutputHandle.java @@ -23,7 +23,11 @@ public class EncodedOutputHandle extends HandleGeneric public EncodedOutputHandle( OutputStream stream, String encoding ) { - super( stream ); + this( makeWriter( stream, encoding ) ); + } + + private static BufferedWriter makeWriter( OutputStream stream, String encoding ) + { if( encoding == null ) encoding = "UTF-8"; OutputStreamWriter streamWriter; try @@ -34,7 +38,7 @@ public class EncodedOutputHandle extends HandleGeneric { streamWriter = new OutputStreamWriter( stream ); } - this.m_writer = new BufferedWriter( streamWriter ); + return new BufferedWriter( streamWriter ); } @Nonnull