File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
src/main/java/io/github/fvarrui/javapackager/utils Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -326,5 +326,20 @@ public static boolean exists(File file) {
326326 public static boolean folderContainsFile (File folder , String filename ) {
327327 return new File (folder , filename ).exists ();
328328 }
329+
330+ /**
331+ * Writes String to a file in UTF-8 including BOM
332+ * @param output Output file
333+ * @param data Input string
334+ * @throws Exception if something goes wrong
335+ */
336+ public static void writeStringToFileWithBOM (File output , String data ) throws Exception {
337+ FileOutputStream fileOutputStream = new FileOutputStream (output );
338+ // write utf-8 BOM
339+ byte [] uft8bom = { (byte ) 0xef , (byte ) 0xbb , (byte ) 0xbf };
340+ fileOutputStream .write (uft8bom );
341+ fileOutputStream .write (data .getBytes (StandardCharsets .UTF_8 ));
342+ fileOutputStream .close ();
343+ }
329344
330345}
You can’t perform that action at this time.
0 commit comments