Here you can find the source of writeFile(File file, String text)
Parameter | Description |
---|---|
file | a parameter |
text | a parameter |
public static boolean writeFile(File file, String text)
//package com.java2s; /*/*from w w w . ja va 2 s . co m*/ * Copyright 2009 Yodlee, Inc. All Rights Reserved. Your use of this code * requires a license from Yodlee. Any such license to this code is * restricted to evaluation/illustrative purposes only. It is not intended * for use in a production environment, and Yodlee disclaims all warranties * and/or support obligations concerning this code, regardless of the terms * of any other agreements between Yodlee and you." */ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; public class Main { /** * Write to File * * @param file * @param text * @return boolean sucess of writing to file */ public static boolean writeFile(File file, String text) { return writeFile(file.toString(), text); } /** * Write to File * * @param filename * the filename * @param text * text to write * @reutrn success. */ public static boolean writeFile(String filename, String text) { try { FileOutputStream os = new FileOutputStream(filename); byte textBytes[] = text.getBytes(); os.write(textBytes, 0, textBytes.length); } catch (IOException ioe) { ioe.printStackTrace(); return false; } catch (Exception e) { e.printStackTrace(); return false; } return true; } }