Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import java.util.ArrayList;
import java.util.List;

public class Main {
    private static List<String> allTransactions(String pdfTextForm) {
        String[] lines = pdfTextForm.split("\n"); //New line splitter
        int transactionNumber = 1;
        StringBuilder onetransactionStr = new StringBuilder();
        boolean isTransactionFound = false;
        List<String> allTransaction = new ArrayList<>();
        for (String l : lines) {
            // System.out.println("current line :" + l);
            if (l.trim().equals(transactionNumber + "")) {
                isTransactionFound = true;
                onetransactionStr.append(l).append(" ");
            } else if (l.trim().equals((transactionNumber + 1 + ""))) {
                transactionNumber++;
                allTransaction.add(onetransactionStr.toString());
                onetransactionStr.delete(0, onetransactionStr.length());
                onetransactionStr.append(l).append(" ");
            } else if (l.contains("Opening balance") || l.contains("Closing balance")) // End of all transactions
            {
                allTransaction.add(onetransactionStr.toString());
                break;
            } else if (isTransactionFound) {
                onetransactionStr.append(l).append(" ");
            }
        }

        return allTransaction;
    }
}