Here you can find the source of createFile(String filePath, String content)
public static void createFile(String filePath, String content)
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.nio.charset.Charset; public class Main { public static void createFile(String filePath, String content) { File file = new File(filePath); try {//w ww . ja v a2s . c o m if (!file.exists()) { if (!file.getParentFile().exists()) { file.getParentFile().mkdirs(); } file.createNewFile(); } FileOutputStream fos = new FileOutputStream(file); fos.write(content.getBytes(Charset.forName("UTF-8"))); fos.flush(); fos.close(); } catch (IOException e) { e.printStackTrace(); } } }