파일에서 번호 매겨진 패턴을 찾고 싶습니다. 클래스에서 다른 메서드를 사용하여 원하는 숫자 형식으로 변환하고 싶습니다.) ...문자열을 텍스트 파일의 일부로 바꿉니다.
내 문제는 새로운 숫자 형식을 이전 숫자 형식으로 바꿔서 (나는 모르겠다) 새로운 파일에 쓰고 싶다는 것이다.
String INPUT = "D:\\input.txt";
String OUTPUT = "D:\\output.txt";
String all = "";
Pattern regexp = Pattern.compile("\"(\\d{14}.{2}\\d{4})\"");
try (BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(INPUT), "UTF-8"))) {
String CurrentLine;
while ((CurrentLine = in.readLine()) != null) {
Matcher matcher = regexp.matcher(CurrentLine);
if (matcher.find()) {
String number1 = CurrentLine.substring(10,20);
String number2 = CurrentLine.substring(30,40);
number1 = convertor(number1);
number2 = convertor(number2);
}
all = all + sCurrentLine + "\r\n"; \\create output to use for BufferedWriter
}
BTW 위의 코드 내 전체 코드의 (그것이 명백으로) 단지 일부입니다.
컨버터가 어떤 역할을하는지 명확하지 않습니다 ... – freedev
숫자 형식이 다음과 같다고 가정합니다. 23 + 3 변환기 메서드는 숫자를 합하여 26 + 0을 반환합니다. 입력은 20 자, 변환기 출력도 20 자입니다. – aminspy12