View Javadoc

1   /**
2    * Copyright 2011-2012 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
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  }