Here you can find the source of saveFile(final String filename, final String s1, final String textOut, final String s3)
Parameter | Description |
---|---|
filename | a parameter |
s1 | a parameter |
textOut | a parameter |
s3 | a parameter |
Parameter | Description |
---|---|
IOException | an exception |
public static void saveFile(final String filename, final String s1, final String textOut, final String s3) throws IOException
//package com.java2s; /*//from w w w . j ava2s. com * Copyright (c) 2003 Stephan D. Cote' - All rights reserved. * * This program and the accompanying materials are made available under the * terms of the MIT License which accompanies this distribution, and is * available at http://creativecommons.org/licenses/MIT/ * * Contributors: * Stephan D. Cote * - Initial concept and implementation */ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; public class Main { /** * Save the given text out to the given file. * * @param filename * @param s1 * @param textOut * @param s3 * * @throws IOException */ public static void saveFile(final String filename, final String s1, final String textOut, final String s3) throws IOException { if ((filename != null) && (filename.length() > 0)) { final File file = new File(filename); file.mkdirs(); } final File file1 = new File( String.valueOf((new StringBuffer(String.valueOf(filename))).append(s1).append(s3))); System.out.println("write file ".concat(String.valueOf(file1))); // Delete it if it exists if (file1.exists()) { file1.delete(); } final FileOutputStream fileoutputstream = new FileOutputStream(file1); fileoutputstream.write(textOut.getBytes()); fileoutputstream.close(); } }