Here you can find the source of copyFileLinewise(File inputFile, File outputFile)
Parameter | Description |
---|---|
inputFile | input file (that shall be copied) |
outputFile | destination file |
Parameter | Description |
---|---|
IOException | thrown if reading or writing has failed |
public static void copyFileLinewise(File inputFile, File outputFile) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { /**/*from w w w . j a v a2 s .c om*/ * Copies one file linewise to another file. * * @param inputFile input file (that shall be copied) * @param outputFile destination file * @throws IOException thrown if reading or writing has failed */ public static void copyFileLinewise(File inputFile, File outputFile) throws IOException { try { BufferedReader r = new BufferedReader(new FileReader(inputFile)); BufferedWriter w = new BufferedWriter(new FileWriter(outputFile)); String line; while ((line = r.readLine()) != null) { w.write(line); w.newLine(); } w.close(); r.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } } }