I am facing a problem: I have a CSV file to prepare and remove the value. Here's the code (and works fine):
Remove public squares {last int [] ID = new int [] {0, 10}; Last difference [] NAME = new int [] (15, 45}; public static zero main (string array []) {FileInputStream fis = new FileInputStream ("C: \\ cnab.txt"); string line; while (( Line = fis.readLine ()) = null {System.out.println (getValue (line, id)); System.out.println (getValue (line, NAME))}} private string getValue (string line, int [] Slice) {return line. Substring (piece [0], piece [1]);}
}
By that time, I'm fine Readable, elegant, like:
System.out.println (line.getValue (name));
But all of us Know that the string is the last (and should be the same). Anyone have any suggestions?
Option will have an enum where you currently have ARA arrays:
public enum field {ID (0, 10), NAME (15, 45); personal finals start; private end end end ; Private field (int start, int end) {this.start = start; This.end = end;} By removing public string (string line) {return line.substring (start, end); }}
then:
System.out.println (field. NAME.extractFrom (line)); Println (Fields.ID.extractFrom (line));
This means that you can pass the field without any kind of code (such as the set of fields required for verification), and you want to have any other Can add custom methods and information. (For example, you may have a pattern
area for verification ...)
No comments:
Post a Comment