Here you can find the source of saveToDisk(InputStream is, String filename)
Parameter | Description |
---|---|
is | a parameter |
filename | a parameter |
Parameter | Description |
---|---|
FileNotFoundException | an exception |
IOException | an exception |
public static void saveToDisk(InputStream is, String filename) throws FileNotFoundException, IOException
//package com.java2s; /* bcwti/*w w w.j a v a 2s.co m*/ * * Copyright (c) 2011 Parametric Technology Corporation (PTC). All Rights * Reserved. * * This software is the confidential and proprietary information of PTC * and is subject to the terms of a software license agreement. You shall * not disclose such confidential information and shall use it only in accordance * with the terms of the license agreement. * * ecwti */ import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; public class Main { /** * save primary conetent to local * @param is * @param filename * @throws FileNotFoundException * @throws IOException */ public static void saveToDisk(InputStream is, String filename) throws FileNotFoundException, IOException { FileOutputStream fos = new FileOutputStream(filename); byte[] buf = new byte[1024]; int len = 0; while ((len = is.read(buf)) > 0) { fos.write(buf, 0, len); } fos.flush(); fos.close(); } }