Created
March 8, 2025 19:43
-
-
Save pablohdzvizcarra/4cc1d510414f4e18bd3928068769082f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.IOException; | |
import java.nio.file.Files; | |
import java.nio.file.Paths; | |
import java.util.List; | |
public class Example1 { | |
public static void main(String[] args) { | |
String filePath = "data.txt"; | |
try { | |
List<String> lines = Files.readAllLines(Paths.get(filePath)); | |
for (String line : lines) { | |
System.out.println(line); | |
} | |
} 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