Advertisement
Guest User

Untitled

a guest
Dec 17th, 2014
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.43 KB | None | 0 0
  1. private static InputStream checkForUtf8BOM(InputStream inputStream) throws IOException
  2.     {
  3.         PushbackInputStream pushbackInputStream = new PushbackInputStream(new BufferedInputStream(inputStream), 3);
  4.         byte[] bom = new byte[3];
  5.         if (pushbackInputStream.read(bom) != -1)
  6.         {
  7.             if (!(bom[0] == (byte) 0xEF && bom[1] == (byte) 0xBB && bom[2] == (byte) 0xBF))
  8.                 pushbackInputStream.unread(bom);
  9.         }
  10.         return pushbackInputStream;
  11.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement