org.apache.sshd.common.util.io.IoUtils Java Examples

The following examples show how to use org.apache.sshd.common.util.io.IoUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Utils.java    From termd with Apache License 2.0 5 votes vote down vote up
/**
 * @param path The {@link Path} to write the data to
 * @param data The data to write (as UTF-8)
 * @return The UTF-8 data bytes
 * @throws IOException If failed to write
 */
public static byte[] writeFile(Path path, String data) throws IOException {
    try (OutputStream fos = Files.newOutputStream(path, IoUtils.EMPTY_OPEN_OPTIONS)) {
        byte[] bytes = data.getBytes(StandardCharsets.UTF_8);
        fos.write(bytes);
        return bytes;
    }
}
 
Example #2
Source File: Utils.java    From termd with Apache License 2.0 5 votes vote down vote up
/**
 * @param path The {@link Path} to write the data to
 * @param data The data to write (as UTF-8)
 * @return The UTF-8 data bytes
 * @throws IOException If failed to write
 */
public static byte[] writeFile(Path path, String data) throws IOException {
    try (OutputStream fos = Files.newOutputStream(path, IoUtils.EMPTY_OPEN_OPTIONS)) {
        byte[] bytes = data.getBytes(StandardCharsets.UTF_8);
        fos.write(bytes);
        return bytes;
    }
}
 
Example #3
Source File: FixedSftpSubsystem.java    From sftp-fs with Apache License 2.0 4 votes vote down vote up
@Override
protected Map<String, Object> doStat(int id, String path, int flags) throws IOException {
    Path p = resolveFile(path);
    return resolveFileAttributes(p, flags, IoUtils.getLinkOptions(true));
}