/** * Copy a file from one directory to another, or to another file. * * @param original the original file name * @param copy the file name of the copy */ public static void copyFiles(String original, String copy) throws IOException { InputStream in = FileUtils.newInputStream(original); OutputStream out = FileUtils.newOutputStream(copy, false); copyAndClose(in, out); }
FileOutputStream fileOutputStream = new FileOutputStream(fileName); try (InputStream in = v0.getInputStream()) { result = ValueLong.get(IOUtils.copyAndClose(in, fileOutputStream));
private void sendResource( File resource, HttpServletResponse response ) throws IOException { response.setContentLength( (int) resource.length() ); String mimeType = determineMimeType( resource ); response.setContentType( mimeType ); copyAndClose( new FileInputStream( resource ), response.getOutputStream() ); }
/** * Copy a file from one directory to another, or to another file. * * @param original the original file name * @param copy the file name of the copy */ public static void copyFiles(String original, String copy) throws IOException { InputStream in = FileUtils.newInputStream(original); OutputStream out = FileUtils.newOutputStream(copy, false); copyAndClose(in, out); }
/** * Copy a file from one directory to another, or to another file. * * @param original the original file name * @param copy the file name of the copy */ public static void copyFiles(String original, String copy) throws IOException { InputStream in = FileUtils.newInputStream(original); OutputStream out = FileUtils.newOutputStream(copy, false); copyAndClose(in, out); }
public FileObject openFileObject(String fileName, String mode) throws IOException { try { long id = getId(fileName, false); PreparedStatement prep = prepare("SELECT DATA FROM FILEDATA WHERE ID=?"); prep.setLong(1, id); ResultSet rs = prep.executeQuery(); if (rs.next()) { InputStream in = rs.getBinaryStream(1); ByteArrayOutputStream out = new ByteArrayOutputStream(); IOUtils.copyAndClose(in, out); byte[] data = out.toByteArray(); return new FileObjectDatabase(this, fileName, data, false); } else { return new FileObjectDatabase(this, fileName, new byte[0], true); } } catch (SQLException e) { throw convert(e); } }
public void copy(String original, String copy) throws SQLException { try { OutputStream out = openFileOutputStream(copy, false); InputStream in = openFileInputStream(original); IOUtils.copyAndClose(in, out); } catch (IOException e) { throw Message.convertIOException(e, "Can not copy " + original + " to " + copy); } }
public void copy(String original, String copy) throws SQLException { try { OutputStream out = openFileOutputStream(copy, false); InputStream in = openFileInputStream(original); IOUtils.copyAndClose(in, out); } catch (IOException e) { rollback(); throw Message.convertIOException(e, "Can not copy " + original + " to " + copy); } }
FileOutputStream fileOutputStream = new FileOutputStream(fileName); try (InputStream in = v0.getInputStream()) { result = ValueLong.get(IOUtils.copyAndClose(in, fileOutputStream));
InputStream in = v0.getInputStream(); try { result = ValueLong.get(IOUtils.copyAndClose(in, fileOutputStream)); } finally {