java read lines from file
Scanner sc = null;
try {
File file = new File("myfile.txt"); // java.io.File
sc = new Scanner(file); // java.util.Scanner
String line;
while (sc.hasNextLine()) {
line = sc.nextLine();
// process the line
}
}
catch(FileNotFoundException e)
{
e.printStackTrace();
}
finally {
if (sc != null) sc.close();
}
Also in Java:
- convert every character in string to arraylist jva
- java how to change the length of an array
- java stream remove
- how to make a list java
- java substring
- how to make a new arraylist java
- covariant type in java
- hashset contains java
- how to make a variable unchangeable in java
- foreach java
- main method java
- android get distance between two locations kotlin
- change fragment in android studio
- Java copy file
- continue in java
- java optional to collection
- check last character of string java
- java print type of object
- get raondom from array java
- check if a char is a space java
- java store hexadecimal value
- jstl core tags
- JFrame text java
- java int passed by reference