common_helper/src/main/java/com/xiongyingqi/util/FileHelper.java
public static File readInputStream(InputStream inputStream, File file) {
        try {
            validateFile(file);
        } catch (Exception e2) {
            e2.printStackTrace();
        }
        try {
            FileOutputStream outputStream = new FileOutputStream(file);
            int length = -1;
            try {
                int bufferSize = 128;
                byte[] buffer = new byte[bufferSize];
                while ((length = inputStream.read(buffer)) != -1) {
                    if (length != bufferSize) {
                        System.arraycopy(buffer, 0, buffer, 0, length);
                    }
                    outputStream.write(buffer);
                }
            } catch (IOException e) {
                LOGGER.error(e);
            } finally {
                // try {
                // inputStream.close();
                // } catch (IOException e1) {
                // e1.printStackTrace();
                // }
                try {
                    inputStream.close();
                } catch (IOException e1) {
                    e1.printStackTrace();
                }
                try {
                    outputStream.flush();
                } catch (IOException e) {
                    LOGGER.error(e);
                }
                try {
                    outputStream.close();
                } catch (IOException e) {
                    LOGGER.error(e);
                }
            }
        } catch (FileNotFoundException e1) {
            e1.printStackTrace();
            return null;
        }
        return file;
    }
public static File readInputStream(InputStream inputStream, File file) {
        try {
            validateFile(file);
        } catch (Exception e2) {
            e2.printStackTrace();
        }
        try {
            FileOutputStream outputStream = new FileOutputStream(file);
            int length = -1;
            try {
                int bufferSize = 128;
                byte[] buffer = new byte[bufferSize];
                while ((length = inputStream.read(buffer)) != -1) {
                    if (length != bufferSize) {
                        System.arraycopy(buffer, 0, buffer, 0, length);
                    }
                    outputStream.write(buffer);
                }
            } catch (IOException e) {
                LOGGER.error(e);
            } finally {
                // try {
                // inputStream.close();
                // } catch (IOException e1) {
                // e1.printStackTrace();
                // }
                try {
                    inputStream.close();
                } catch (IOException e1) {
                    e1.printStackTrace();
                }
                try {
                    outputStream.flush();
                } catch (IOException e) {
                    LOGGER.error(e);
                }
                try {
                    outputStream.close();
                } catch (IOException e) {
                    LOGGER.error(e);
                }
            }
        } catch (FileNotFoundException e1) {
            e1.printStackTrace();
            return null;
        }
        return file;
    }
将流读入到文件内 <br>
2013-9-2 下午10:04:17

@param inputStream
@param file
@return