Split and count Words from the text in the Given Text File and Compare using Comparator [JAVA]

Split and count Words from the text in the Given Text File and Compare using Comparator in Java, It is basically used in big data operations.

package com.yubraj.core;

 * Created by yubraj_pokharel on 5/23/16.

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.*;

public class Main {

    public static void main(String[] args) throws IOException {
        String text_from_file = getTextFromFile();
        text_from_file = trim_non_alpha(text_from_file);
        String[] final_text = text_from_file.split("[- .,]");

        ArrayList<String> myText = new ArrayList<>();
        myText = getStringIntoArrayList(final_text);

        List<HashMap<String, Integer>> final_map = new ArrayList<>();

        HashMap<String, Integer> map = new HashMap<String, Integer>();
        for (String temp : myText) {
            Integer count = map.get(temp);
            map.put(temp, (count == null) ? 1 : count + 1);
        Collections.sort(final_map, new MapComparator());


    private static void print_format(List<HashMap<String, Integer>> final_map) {

        for(int i =0; i<final_map.size(); i++){
            HashMap<String, Integer> new_hashmap = final_map.get(i);
            Set entrySet = new_hashmap.entrySet();
            Iterator it = entrySet.iterator();
            while (it.hasNext()){
                Map.Entry me = (Map.Entry)it.next();
                System.out.println("["+me.getKey()+"] = "+me.getValue());


    private static ArrayList<String> getStringIntoArrayList(String[] final_text) {
        ArrayList<String> tempArray = new ArrayList<>();
        for (int i = 0; i < final_text.length; i++) {
        return tempArray;

    private static String trim_non_alpha(String text) {
        String temp;
        temp = text.replaceAll("\\b\\w+?[0-9]+\\w+?\\b", "").trim();
        return temp;

    private static String getTextFromFile() throws IOException {
        String everything;

        try (BufferedReader br = new BufferedReader(new FileReader("/home/yubraj_pokharel/big_data_Class/input123.txt"))) {
            StringBuilder sb = new StringBuilder();
            String line = br.readLine();

            while (line != null) {
                line = br.readLine();
            everything = sb.toString();
        return everything;

    private static class MapComparator implements Comparator<HashMap<String, Integer>> {
        public int compare(HashMap<String, Integer> first, HashMap<String, Integer> second) {
            String firstValue = first.keySet().iterator().next();
            String secondValue = second.keySet().iterator().next();
            return firstValue.compareTo(secondValue);

this is java and this is awesome

[awesome] = 1
[java] = 1
[and] = 1
[this] = 2
[is] = 2

Happy Coding !!!

Single version & multi-version time stamping example in Transcation(DBMS)

1)    Following non-serial schedule.  Show how this schedule will get executed with single version & multi-version timestamping.  Show the detailed steps.
Start(T1),Write(T1, x), Start(T2), Read(T2, x), Start(T3), Write(T2, x), Write(T3, x), Read(T2, x), Write(T2, x), Commit(T1), Commit(T2), Commit(T3)

We know a non-serial schedule is a schedule where the operations of a group of concurrent transactions are interleaved.Non-serial schedule has no only fix actions of any transaction.

Now according to problem,

single version timestamping

multi-version timestamping

CSS Triangles

You can make them with a single div. It's nice to have classes for each direction possibility. 

<div class="triangle-up"></div>
<div class="triangle-down"></div>
<div class="triangle-left"></div>
<div class="triangle-right"></div>

.triangle-up {
            width: 0;
            height: 0;
            border-left: 50px solid transparent;
            border-right: 50px solid transparent;
            border-bottom: 50px solid black;

.triangle-down {
            width: 0;
            height: 0;
            border-left: 50px solid transparent;
            border-right: 50px solid transparent;
            border-top: 50px solid #f00;

.triangle-right {
            width: 0;
            height: 0;
            border-top: 50px solid transparent;
            border-bottom: 50px solid transparent;
            border-left: 50px solid green;

.triangle-left {
            width: 0;
            height: 0;
            border-top: 50px solid transparent;
            border-bottom: 50px solid transparent;
            border-right:50px solid blue;