Here you can find the source of writeToFile(final String path, final String content)
Parameter | Description |
---|---|
path | the path to the file |
content | the content to write |
Parameter | Description |
---|---|
IOException | if writting to the file fails |
public static void writeToFile(final String path, final String content) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.IOException; import java.io.RandomAccessFile; public class Main { /**// www.j a va 2s .co m * Dumps a string into a file. * <p> * If the file does not exits it is created. Otherwise, if it already exists it * overwritten. * * @param path the path to the file * @param content the content to write * @throws IOException if writting to the file fails */ public static void writeToFile(final String path, final String content) throws IOException { final File file = new File(path); final RandomAccessFile access = new RandomAccessFile(file, "rws"); try { access.writeBytes(content); } finally { access.close(); } } }