Skip to content

Instantly share code, notes, and snippets.

@pablohdzvizcarra
Created March 8, 2025 19:48
Show Gist options
  • Save pablohdzvizcarra/1aef8a860e621f41d32687f3ac8848fa to your computer and use it in GitHub Desktop.
Save pablohdzvizcarra/1aef8a860e621f41d32687f3ac8848fa to your computer and use it in GitHub Desktop.
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
public class Example3 {
public static void main(String[] args) {
String filePath = "data.txt";
try {
byte[] contentBytes = Files.readAllBytes(Paths.get(filePath));
for (byte b : contentBytes) {
char letter = (char) b;
System.out.println(letter);
}
} catch (IOException e) {
System.out.println("An error ocurred reading the file: " + e.getMessage());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment