Skip to content

Instantly share code, notes, and snippets.

@japharr
Created September 12, 2022 11:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save japharr/8aca32ed3a1a972f345b04713be53d1c to your computer and use it in GitHub Desktop.
Save japharr/8aca32ed3a1a972f345b04713be53d1c to your computer and use it in GitHub Desktop.
Text file parser
package com.example.demo.controller;
import java.util.ArrayList;
import java.util.List;
public class Record {
private String desId;
private String sourceId;
public static void main(String[] args) {
List<String> contents = new ArrayList<>();
List<Record> records = new ArrayList<>();
for(int i=0; i<contents.size(); i++) {
if(i<5) continue;
int j = i;
String line = contents.get(i);
if(line.trim().startsWith("Destination Identifier")) {
String desId = line.substring(27, 68).trim();
String desCurCode = line.substring(93).trim();
String line2 = contents.get(i+1);
String line3 =contents.get(i+2);
Record record = new Record(desId, decu);
records.add(record);
i += 8;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment