1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package com.dhptech.maven.stripbom;
17
18 import java.io.File;
19 import java.io.IOException;
20 import java.io.OutputStream;
21 import java.util.List;
22
23 import org.apache.commons.io.FileUtils;
24
25
26
27
28 public class CreateTestResources {
29 public static void main(String[] args) {
30 try {
31 String s = "The quick brown fox jumped over the lazy dog";
32 byte[] normal = s.getBytes();
33 List<byte[]> boms = new ByteOrderMarkMojo().getBoms();
34 File directory = new File("/Users/jeffcaddel/ws/bom-maven-plugin/src/test/resources");
35 File file1 = new File(directory + "/normal.txt");
36 FileUtils.writeByteArrayToFile(file1, normal);
37 File file2 = new File(directory + "/utf8-bom.txt");
38 File file3 = new File(directory + "/utf16-bom1.txt");
39 File file4 = new File(directory + "/utf16-bom2.txt");
40 write(file2, boms.get(0), normal);
41 write(file3, boms.get(1), normal);
42 write(file4, boms.get(2), normal);
43 } catch (Exception e) {
44 e.printStackTrace();
45 }
46 }
47
48 protected static void write(File file, byte[] bom, byte[] data) throws IOException {
49 OutputStream out = FileUtils.openOutputStream(file);
50 out.write(bom);
51 out.write(data);
52 out.close();
53 }
54 }