GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Create Readtxt.java · shivgy/Java@ed59a1c

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • Readtxt.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎Readtxt.java‎

Copy file name to clipboard
+39Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package readtextfile;
2+
import java.io.IOException;
3+
import java.nio.charset.Charset;
4+
import java.nio.charset.StandardCharsets;
5+
import java.nio.file.Path;
6+
import java.nio.file.Paths;
7+
import java.util.Scanner;
8+
9+
public class ReadTxt {
10+
final static String FILE_NAME = "C:\\Users\\Gopal\\Desktop\\infosys.txt";
11+
final static Charset ENCODING = StandardCharsets.UTF_8;
12+
//static Path path = Paths.get(FILE_NAME);
13+
14+
public static void main(String[] args) throws IOException {
15+
ReadTxt text = new ReadTxt();
16+
text.readFile(FILE_NAME);
17+
}
18+
19+
public void readFile(String aFileName)throws IOException{
20+
Path path = Paths.get(aFileName);
21+
try(Scanner sc = new Scanner(path,ENCODING.name())){
22+
while(sc.hasNextLine()){
23+
String str = sc.nextLine();
24+
25+
/*ERM Device*/
26+
if(str.contains("$SLU")){
27+
str = str.substring(str.indexOf("$SLU"), str.indexOf("#"));
28+
System.out.println(str.substring(4,19));
29+
//System.out.println(str);
30+
}
31+
//SUN100 Device
32+
if(str.contains("Recieved packet:")){
33+
str = str.substring(str.indexOf("$SUN"), str.indexOf("|#"));
34+
System.out.println(str.substring(str.length()-15, str.length()));
35+
}
36+
}
37+
}
38+
}
39+
}

0 commit comments

Comments
0 (0)
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.