Skip to content

Commit 3b3cd9c

Browse files
committed
[Java] Remove use of FileInputStream.
1 parent bc42a78 commit 3b3cd9c

File tree

4 files changed

+20
-11
lines changed

4 files changed

+20
-11
lines changed

sbe-samples/src/main/java/uk/co/real_logic/sbe/examples/OtfExample.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@
2929
import uk.co.real_logic.sbe.xml.ParserOptions;
3030
import uk.co.real_logic.sbe.xml.XmlSchemaParser;
3131

32-
import java.io.FileInputStream;
33-
import java.io.IOException;
34-
import java.io.InputStream;
35-
import java.io.PrintWriter;
32+
import java.io.*;
3633
import java.nio.ByteBuffer;
34+
import java.nio.file.Files;
35+
import java.nio.file.Path;
36+
import java.nio.file.Paths;
3737
import java.util.List;
3838

3939
public class OtfExample
@@ -93,7 +93,8 @@ public static void main(final String[] args) throws Exception
9393

9494
private static void encodeSchema(final ByteBuffer byteBuffer) throws Exception
9595
{
96-
try (InputStream in = new FileInputStream("src/main/resources/example-schema.xml"))
96+
final Path path = Paths.get("src/main/resources/example-schema.xml");
97+
try (InputStream in = new BufferedInputStream(Files.newInputStream(path)))
9798
{
9899
final MessageSchema schema = XmlSchemaParser.parse(in, ParserOptions.DEFAULT);
99100
final Ir ir = new IrGenerator().generate(schema);

sbe-tool/src/main/java/uk/co/real_logic/sbe/xml/XmlSchemaParser.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ public static void validate(final String xsdFilename, final InputStream in) thro
7373
}
7474

7575
/**
76-
* Take an {@link InputStream} and parse it generating map of template ID to Message objects, types, and schema
77-
* Input could be from {@link java.io.FileInputStream}, {@link java.io.ByteArrayInputStream}, etc.
76+
* Take an {@link InputStream} and parse it generating map of template ID to Message objects, types, and schema.
77+
*
7878
* Exceptions are passed back up for any problems.
7979
*
8080
* @param in stream from which schema is read.

sbe-tool/src/test/java/uk/co/real_logic/sbe/generation/java/CompositeElementsGenerationTest.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,13 @@
3636
import uk.co.real_logic.sbe.xml.ParserOptions;
3737
import uk.co.real_logic.sbe.xml.XmlSchemaParser;
3838

39-
import java.io.FileInputStream;
39+
import java.io.BufferedInputStream;
4040
import java.io.IOException;
4141
import java.io.InputStream;
4242
import java.nio.ByteBuffer;
43+
import java.nio.file.Files;
44+
import java.nio.file.Path;
45+
import java.nio.file.Paths;
4346

4447
import static org.hamcrest.core.Is.is;
4548
import static org.hamcrest.Matchers.not;
@@ -209,7 +212,8 @@ private static int encodeTestMessage(final ByteBuffer buffer)
209212

210213
private static void encodeSchema(final ByteBuffer buffer) throws Exception
211214
{
212-
try (InputStream in = new FileInputStream("src/test/resources/composite-elements-schema.xml"))
215+
final Path path = Paths.get("src/test/resources/composite-elements-schema.xml");
216+
try (InputStream in = new BufferedInputStream(Files.newInputStream(path)))
213217
{
214218
final MessageSchema schema = XmlSchemaParser.parse(in, ParserOptions.DEFAULT);
215219
final Ir ir = new IrGenerator().generate(schema);

sbe-tool/src/test/java/uk/co/real_logic/sbe/json/JsonPrinterTest.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,13 @@
2525
import uk.co.real_logic.sbe.xml.ParserOptions;
2626
import uk.co.real_logic.sbe.xml.XmlSchemaParser;
2727

28-
import java.io.FileInputStream;
28+
import java.io.BufferedInputStream;
2929
import java.io.IOException;
3030
import java.io.InputStream;
3131
import java.nio.ByteBuffer;
32+
import java.nio.file.Files;
33+
import java.nio.file.Path;
34+
import java.nio.file.Paths;
3235

3336
import static junit.framework.TestCase.assertEquals;
3437

@@ -117,7 +120,8 @@ public void exampleMessagePrintedAsJson() throws Exception
117120

118121
private static void encodeSchema(final ByteBuffer buffer) throws Exception
119122
{
120-
try (InputStream in = new FileInputStream("src/test/resources/json-printer-test-schema.xml"))
123+
final Path path = Paths.get("src/test/resources/json-printer-test-schema.xml");
124+
try (InputStream in = new BufferedInputStream(Files.newInputStream(path)))
121125
{
122126
final MessageSchema schema = XmlSchemaParser.parse(in, ParserOptions.DEFAULT);
123127
final Ir ir = new IrGenerator().generate(schema);

0 commit comments

Comments
 (0)