Skip to content

Commit f69b182

Browse files
committed
Update the outputstream to be created outside the function
1 parent f02290a commit f69b182

File tree

1 file changed

+3
-5
lines changed
  • biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmtf

1 file changed

+3
-5
lines changed

biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmtf/MmtfActions.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,17 @@ public static void writeToFile(Structure structure, Path path) throws IOExceptio
5252
/**
5353
* Write a Structure object to an {@link OutputStream}
5454
* @param structure the Structure to write
55-
* @return the {@link OutputStream} of the MMTF structure
55+
* @param the {@link OutputStream} to write to
5656
* @throws IOException an error transferring the byte[]
5757
*/
58-
public static OutputStream writeToOutputStream(Structure structure) throws IOException{
58+
public void writeToOutputStream(Structure structure, OutputStream outputStream) throws IOException{
5959
// Set up this writer
6060
AdapterToStructureData writerToEncoder = new AdapterToStructureData();
6161
// Get the writer - this is what people implement
6262
new MmtfStructureWriter(structure, writerToEncoder);
6363
// Now write this data to file
6464
byte[] outputBytes = WriterUtils.getDataAsByteArr(writerToEncoder);
65-
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(outputBytes.length);
66-
byteArrayOutputStream.write(outputBytes,0,outputBytes.length);
67-
return byteArrayOutputStream;
65+
outputStream.write(outputBytes,0,outputBytes.length);
6866
}
6967

7068

0 commit comments

Comments
 (0)