GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Java/Readtxt.java at ed59a1ca2bd6c25a267450ec5a53326900c4ca8c · shivgy/Java Expand file tree/ Copy pathReadtxt.javaMore file actions 39 lines (35 loc) · 1.14 KB / Copy pathReadtxt.javaFile metadata and controls39 lines (35 loc) · 1.14 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 package readtextfile; import java.io.IOException; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Scanner; public class ReadTxt { final static String FILE_NAME = "C:\\Users\\Gopal\\Desktop\\infosys.txt"; final static Charset ENCODING = StandardCharsets.UTF_8; //static Path path = Paths.get(FILE_NAME); public static void main(String[] args) throws IOException { ReadTxt text = new ReadTxt(); text.readFile(FILE_NAME); } public void readFile(String aFileName)throws IOException{ Path path = Paths.get(aFileName); try(Scanner sc = new Scanner(path,ENCODING.name())){ while(sc.hasNextLine()){ String str = sc.nextLine(); /*ERM Device*/ if(str.contains("$SLU")){ str = str.substring(str.indexOf("$SLU"), str.indexOf("#")); System.out.println(str.substring(4,19)); //System.out.println(str); } //SUN100 Device if(str.contains("Recieved packet:")){ str = str.substring(str.indexOf("$SUN"), str.indexOf("|#")); System.out.println(str.substring(str.length()-15, str.length())); } } } } } |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |