Java File Save saveFile(InputStream st, File testFile)

Here you can find the source of saveFile(InputStream st, File testFile)

Description

save File

License

Open Source License

Declaration

public static File saveFile(InputStream st, File testFile)
            throws FileNotFoundException, IOException 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2015 Patrick Hofer//from  w ww . j ava  2 s  .c o  m
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Patrick Hofer - initial API and implementation
 *******************************************************************************/

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;

public class Main {
    public static File saveFile(InputStream st, File testFile)
            throws FileNotFoundException, IOException {
        BufferedReader r = new BufferedReader(new InputStreamReader(st));
        String line;
        try (PrintStream wr = new PrintStream(testFile)) {
            while ((line = r.readLine()) != null) {
                wr.println(line);
            }
        }
        return testFile;
    }
}

Related

  1. save(OutputStream out, InputStream iStream)
  2. saveBytesAsIfile(final IFile file, final byte[] bytes)
  3. saveContent(OutputStream os, byte[] content)
  4. saveConvert(String theString, boolean escapeSpace)
  5. saveDoubleMatrix(double[][] matrix, PrintStream out)
  6. saveFile(String fname, byte[] bytes)
  7. saveFile(String where)
  8. saveInputToOutput(InputStream is, OutputStream os)
  9. saveIntArray(int[] array, PrintStream out)