Here you can find the source of write2File(String contents, Path outputPath)
public static void write2File(String contents, Path outputPath)
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.nio.file.*; public class Main { public static void write2File(String contents, Path outputPath) { if (outputPath != null) { try { outputPath.toFile().getParentFile().mkdirs(); Files.write(outputPath, contents.getBytes()); } catch (IOException e) { e.printStackTrace();//from w ww. j av a 2s . c o m } } } }