Skip to content

Commit

Permalink
Restore plugin method
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertBColton committed Jun 12, 2018
1 parent 51ba5fe commit 1ebe4f4
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions org/lateralgm/main/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@
import java.awt.image.RGBImageFilter;
import java.awt.image.WritableRaster;
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
Expand Down Expand Up @@ -192,6 +194,21 @@ public static byte[] readFully(File file) throws FileNotFoundException, IOExcept
return fileData;
}

public static ByteArrayOutputStream readFully(InputStream in) throws IOException
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();

byte[] buffer = new byte[4096];

// Read in the bytes
int numRead = 0;
while ((numRead = in.read(buffer)) >= 0)
baos.write(buffer,0,numRead);

// Close the input stream and return bytes
return baos;
}

public static byte[] readFully(String path) throws FileNotFoundException, IOException
{
return Util.readFully(new File(path));
Expand Down

0 comments on commit 1ebe4f4

Please sign in to comment.