expectHeader(input, protocol.fileEnd());
expectHeader(input, protocol.fileEnd());
private void writeFile(final File localPath, final File file, final FlushableDataOutput output) throws IOException { output.writeByte(protocol.fileStart()); output.writeByte(protocol.paramFilePath()); output.writeUTF(getRelativePath(localPath, file)); output.writeByte(protocol.paramFileSize()); if (file.isDirectory()) { output.writeLong(0L); output.writeByte(protocol.fileEnd()); return; } else { output.writeLong(file.length()); } InputStream inputStream = null; try { inputStream = new FileInputStream(file); byte[] buffer = new byte[8192]; int len; while ((len = inputStream.read(buffer)) != -1) { output.write(buffer, 0, len); } } finally { if (inputStream != null) { try { inputStream.close(); } catch (IOException ignored) { } } } output.writeByte(protocol.fileEnd()); }
private void writeFile(final File localPath, final File file, final FlushableDataOutput output) throws IOException { output.writeByte(protocol.fileStart()); output.writeByte(protocol.paramFilePath()); output.writeUTF(getRelativePath(localPath, file)); output.writeByte(protocol.paramFileSize()); output.writeLong(file.length()); InputStream inputStream = null; try { inputStream = new FileInputStream(file); byte[] buffer = new byte[8192]; int len; while ((len = inputStream.read(buffer)) != -1) { output.write(buffer, 0, len); } } finally { if (inputStream != null) { try { inputStream.close(); } catch (IOException ignored) { } } } output.writeByte(protocol.fileEnd()); }