support for copy codec for avconv
[meviz.git] / src / main / java / eu / svjatoslav / meviz / bomremove / Main.java
index a377f04..9eed788 100755 (executable)
@@ -1,7 +1,7 @@
 /*
  * Meviz - Various tools collection to work with multimedia.
  * Copyright (C) 2012, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
- * 
+ *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of version 2 of the GNU General Public License
  * as published by the Free Software Foundation.
@@ -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();
 
@@ -60,7 +60,7 @@ public class Main implements Module {
 
        @Override
        public String getDescription() {
-               return "Remove byte order mark (bom) from UTF text files of they are present.";
+               return "Remove byte order mark (bom) from UTF text files if they are present.";
        }
 
        @Override
@@ -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);
        }