From 2c9f2e98f8ebf36f1d288742de37424589c556e0 Mon Sep 17 00:00:00 2001 From: Svjatoslav Agejenko Date: Fri, 8 Feb 2013 13:28:31 +0200 Subject: [PATCH] fixed BOM header --- src/main/java/eu/svjatoslav/meviz/Main.java | 2 +- src/main/java/eu/svjatoslav/meviz/bomremove/Main.java | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/eu/svjatoslav/meviz/Main.java b/src/main/java/eu/svjatoslav/meviz/Main.java index 58ae6b7..8e2f4f1 100755 --- a/src/main/java/eu/svjatoslav/meviz/Main.java +++ b/src/main/java/eu/svjatoslav/meviz/Main.java @@ -34,7 +34,7 @@ public class Main { modules.add(new eu.svjatoslav.meviz.renamer.Main()); modules.add(new eu.svjatoslav.meviz.grabmemcard.Main()); modules.add(new eu.svjatoslav.meviz.textsplitter.Main()); - + modules.add(new eu.svjatoslav.meviz.bomremove.Main()); } public static void main(final String[] args) throws Exception { diff --git a/src/main/java/eu/svjatoslav/meviz/bomremove/Main.java b/src/main/java/eu/svjatoslav/meviz/bomremove/Main.java index a377f04..6cb3c7f 100755 --- a/src/main/java/eu/svjatoslav/meviz/bomremove/Main.java +++ b/src/main/java/eu/svjatoslav/meviz/bomremove/Main.java @@ -21,7 +21,7 @@ import eu.svjatoslav.meviz.Module; public class Main implements Module { - byte[] bomHeader = new byte[] { (byte) 0xfe, (byte) 0xff }; + byte[] bomHeader = new byte[] { (byte) 0xef, (byte) 0xbb, (byte) 0xbf }; CommandlineHandler commandlineHandler = new CommandlineHandler(); @@ -41,7 +41,7 @@ public class Main implements Module { final FileInputStream fileInputStream = new FileInputStream(file); - final byte[] currentFileHeader = new byte[2]; + final byte[] currentFileHeader = new byte[bomHeader.length]; fileInputStream.read(currentFileHeader); fileInputStream.close(); @@ -88,12 +88,13 @@ public class Main implements Module { public void processFile(final File file) throws IOException { - if (file.length() < 2) + if (file.length() < bomHeader.length) return; if (!fileContainsHeader(file)) return; + System.out.println("Removing BOM from: " + file.getAbsolutePath()); stripFileFromHeader(file); } -- 2.20.1