Skip to content

Instantly share code, notes, and snippets.

@Mai-Lapyst
Created March 10, 2021 17:28
Show Gist options
  • Save Mai-Lapyst/fe16a1ca9dd28ec240f20fc2813cef1c to your computer and use it in GitHub Desktop.
Save Mai-Lapyst/fe16a1ca9dd28ec240f20fc2813cef1c to your computer and use it in GitHub Desktop.
simple cat like java application; used to test graalvm --static builds
import java.io.*;
import java.nio.*;
import java.nio.charset.*;
import java.nio.file.*;
public class SimpleCat {
public static void main(String[] args) {
Path file = FileSystems.getDefault().getPath(args[0]);
Charset charset = Charset.forName("US-ASCII");
try (BufferedReader reader = Files.newBufferedReader(file, charset)) {
String line = null;
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
} catch (IOException x) {
System.err.format("IOException: %s%n", x);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment