Java tutorial
//package com.java2s; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; public class Main { private static void saveFileForLocal(String requestPath, String result) { // TODO Auto-generated method stub File file = new File(requestPath); if (!file.exists()) { try { File parentFile = file.getParentFile(); if (!parentFile.exists()) { parentFile.mkdirs(); } file.createNewFile(); FileOutputStream fout = new FileOutputStream(file); byte[] buffer = result.getBytes(); fout.write(buffer); fout.close(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }