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

The following examples show how to use org.apache.sshd.common.util.io.IoUtils. These examples are extracted from open source projects. 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 Project: termd   Source File: Utils.java    License: 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 Project: termd   Source File: Utils.java    License: 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 Project: sftp-fs   Source File: FixedSftpSubsystem.java    License: 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));
}