Here you can find the source of createFile(String filePathAndName, String fileContent)
public void createFile(String filePathAndName, String fileContent)
//package com.java2s; import java.io.BufferedWriter; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; public class Main { private String message; public void createFile(String filePathAndName, String fileContent) { try {//from w w w . j a v a 2 s .c o m String filePath = filePathAndName; filePath = filePath.toString(); File myFilePath = new File(filePath); if (!myFilePath.exists()) { myFilePath.createNewFile(); } } catch (Exception e) { message = ""; e.printStackTrace(); } } public static void createFile(String file, String content, String encodType) throws IOException { FileOutputStream writerStream = new FileOutputStream(file); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter( writerStream, encodType)); writer.write(content); writer.close(); writerStream.close(); } }