package java_streamreadtextfile; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.logging.Level; import java.util.logging.Logger; import java.util.stream.Stream; /** * * @web http://java-buddy.blogspot.com/ */ public class Java_StreamReadTextFile { //final static String FILE_NAME = "/proc/cpuinfo"; //final static String FILE_NAME = "/proc/version"; final static String FILE_NAME = "/proc/meminfo"; public static void main(String[] args) { Path path = Paths.get(FILE_NAME); try { Stream<String> fileLines = Files.lines(path); fileLines.forEach((line) -> System.out.println(line)); } catch (IOException ex) { Logger.getLogger(Java_StreamReadTextFile.class.getName()).log(Level.SEVERE, null, ex); } } }
- Parse /proc/meminfo using Java code
how to download this
ReplyDelete