Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Below is the sample input file. I need the sample output file to be written in txt file as shown below. Below is the sample

Below is the sample input file.

image text in transcribed

I need the sample output file to be written in txt file as shown below.

image text in transcribed

Below is the sample Java code that needs to be re-written to capture only src2 records with the transactions information (in the sample output file we can see only for CCX). Please add extra records to test it out your written code before sending it to me. I have already been given multiple solutions and none of them giving to me expected results. The code should check for src2 and corresponding transaction number until that transaction number is finished in the file then write it to the text file for particular src2 {"AES", "CCX", "CIF", "MSB", "PTT", "SEI", "TD1", "TD2", "TD3", "TSP", "TSX", "PAP", "USR"}; In the output file I wanted to the first 5 lines, followed by the transaction related to src2 that need to be extracted. Again, please add multiple records and test it before sending the solution. Currently below code only searched for src2 and printing those lines where src2 are listed, but I need the whole information related to src2 to which the transaction number is tied, so I need information until the where the transaction information is ended for particular src2. So code should search for src2 and transaction number associated with it, until it reaches to different transaction number. Below is the start of next transaction number for Y28 which shouldn't be written into the file. But all the information before it should be written into text file as show in the screenshot above.

F01120707112912346 .000 Y28 AUTO HOLD 07 DEC 24 09:11:32 89.0 85.0 101.0 SYSTEM Y28

package FileProcessing;

import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException;

public class FileProcessing {

public static void main(String[] args) { // Input and output file paths String inputFile = "C:\\\\Users\\\\mua2643\\\\OneDrive - MUFG Union Bank\\\\MUB_Dedicated\\\\FileProcessingApproach3\\\\src\\\\FileProcessing\\\\sampleFile.txt"; String outputFile = inputFile + ".data.txt"; try (BufferedReader reader = new BufferedReader(new FileReader(inputFile)); BufferedWriter writer = new BufferedWriter(new FileWriter(outputFile))) { String line; // Read each line from input file while ((line = reader.readLine()) != null) { // Check if the transaction record is eligible for src2 if (isEligibleForSrc2(line)) { // If the record is eligible, write it to the output file writer.write(line + " "); } } } catch (IOException e) { e.printStackTrace(); } }

// Method to check if a transaction record is eligible for src2 public static boolean isEligibleForSrc2(String record) { // Split the transaction record by spaces String[] fields = record.split("\\s+");

// Array of source systems that indicate if a transaction record is eligible or not String[] src2 = {"AES", "CCX", "CIF", "MSB", "PTT", "SEI", "TD1", "TD2", "TD3", "TSP", "TSX", "PAP", "USR"};

// Check if the record contains a source system from src2 for (String src : src2) { if (record.contains(src)) { return true; } }

return false; } }

Fe11297a7112912345 - Natch 1 [Field Based Scanning Risk Entity Natch]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Shamkant B. Navathe

7th Edition Global Edition

1292097612, 978-1292097619

More Books

Students also viewed these Databases questions