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 master · shivgy/Java Expand file tree/ Copy pathReadtxt.javaMore file actions 46 lines (41 loc) · 1.28 KB / Copy pathReadtxt.javaFile metadata and controls46 lines (41 loc) · 1.28 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 40 41 42 43 44 45 46 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\\...\\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{ Set mySet = new HashSet<>(); Path path = Paths.get(aFileName); try(Scanner sc = new Scanner(path,ENCODING.name())){ while(sc.hasNextLine()){ String str = sc.nextLine(); /*ABC Device*/ if(str.contains("$ABC")){ str = str.substring(str.indexOf("$XYZ"), str.indexOf("|#")); str = str.substring(str.length()-15, str.length()); mySet.add(str); } //XYZ Device if(str.contains("Recieved packet:")){ str = str.substring(str.indexOf("$XYZ"), str.indexOf("|#")); System.out.println(str.substring(str.length()-15, str.length())); } } System.out.println(mySet); } catch(Exception e){ System.out.println(e.toString()); System.out.println(mySet); } } } |
| You are visitor 01402775 — 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. |