June 28, 2019

FileReader BufferedReader example in java

/**
 * TransformatoreFileReader.Java
 *
 * <p>The aim of this class is to read all cobol file
 *
 * Four main methods will be create, read, read&write, and close fileReader
 *
 * BufferedReader to read line by line
 *
 * location : E:\cfed\regional_office\input_files </p>
 */
package com.konzern.transformatore.utils;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import com.konzern.transformatore.utilsInf.TransformatoreFileReaderInf;

/**
 * @author consumerfed
 * @since 8281-80-80-29
 * @version 1.0
 *
 */
public class TransformatoreFileReader implements TransformatoreFileReaderInf {

private static Map<String, BufferedReader> fileInputs = null;

static {
fileInputs = new HashMap<>();
}

/**
* <p> To Read all cobol files in a particular directory
*
* @param location
* @param characterEncoding
* @return Map<String, BufferedReader>
* @throws FileNotFoundException
* @throws IOException
*/
public static Map<String, BufferedReader> creatInputFiles(String location, String characterEncoding) throws FileNotFoundException, IOException {

File fileDirectory = new File(location);
for (File filePath : fileDirectory.listFiles()) {
BufferedReader br = null;
try (FileReader fr = new FileReader(filePath.getAbsolutePath())) {
br = new FileReader(fr);
fileInputs.put(filePath.getName(),br);
if(null!=br) {
br.close();
}
}

}
return fileInputs;
}

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub

try {
Map<String, BufferedReader> i = creatInputFiles("E:\\consumerfed\\bithesh\\input_files", "ASCII");
System.out.println(i);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}

}



Tik Toc Toe in python, two player game, playing with computer complete source code available soon...

June 21, 2019

Cobol to Java Converter - A translator project that converts cobol code to java

Hi

We are trying to make an initiative to make a Java Project that convert Cobol code into Java.

The project on going one

so the latest code will be updated in the repository

https://github.com/konzerntech/CobolToJava



Thanks

I T Section
Consumerfed
Kozhikode 

June 14, 2019

Consumerfed intranet application developed for regional office kozhikode

Consumerfed intranet application developed for regional office kozhikode


Created an intranet for other sections operating inside kozhikode regional office.

* Helps to communicate with other employees effectively

* Helps to assign the task efficiently.

* Communication is easy now

* It cannot access from outside.

* Deployed on a dedicated server.








Just watch the video...

Feel free to comment...
v

June 07, 2019

Artificial Intelligence Robot prototype in Java

Developed a prototype of Artifical Intelligence robot, that can walk a maximum of 5 kilometer on battery charge
For each 1 kg of weight additional charge is used.

Please see the full source code

/**
 *
 */
package com.konzerntech.airobo.model;

/**
 * @author konzerntech
 *
 */
public class AIRobot {

// MILEGE IN KILO METER
private static final float MAX_MILEAGE = 5;

// BATTERY RESERVICE IN PERCENAGE
private static final float BATTERY_RESERVE = 15;

// EXTRA PERCENTAGE REDUCTION PER KILO METER
private static final float EXTRA_REDUCE_PKM_WGT = 2;

// private battery consumption per kilo meter
private static final float BATTERY_CONSUMPTION_PKM = 20;

// WEIGHT IN KILO GRAM
private static final float MAX_WEIGHT = 10;

private float batteryStatus = 0;

private boolean display = false;

private String message = null;

private float weightCarried = 0;



public boolean isDisplay() {
return display;
}

public void setDisplay(boolean display) {
this.display = display;
}

public String getMessage() {
if (null == message) {
message = "";
}
return message;
}

public void setMessage(String message) {
this.message = message;
}

public float getBatteryStatus() {
return batteryStatus;
}

public void setBatteryStatus(float batteryStatus) {
this.batteryStatus = batteryStatus;
}

public float getWeightCarried() {
return weightCarried;
}

public void setWeightCarried(float weightCarried) {
this.weightCarried = weightCarried;
}

public void walk(float kilometer) {
if (checkMaxDistance(kilometer))
batteryConsumption(kilometer, getWeightCarried());
print();
}

public void walkWithWeight(float kilometer, float kilogram) {
/*setWeightCarried(kilogram);
if (checkMaxWeight(kilogram) && checkMaxDistance(kilometer)) {
walk(kilometer);
print();
}*/
carriesWeight(kilogram);
walk(kilometer);
}

public void carriesWeight(float kilogram) {
if (checkMaxWeight(kilogram))
setWeightCarried(kilogram);
}

private boolean checkMaxDistance(float kilometer) {
if (calcMaxMilege(kilometer) < kilometer) {
return false;
}
return true;
}

private float calcMaxMilege(float kilometer) {
float weight = getWeightCarried();
float maxMilege = 100 / (BATTERY_CONSUMPTION_PKM + (EXTRA_REDUCE_PKM_WGT * weight));
return maxMilege;
}



private void batteryConsumption(float kilometer, float weight) {
float charge = getBatteryStatus();
float extraChargeConsumed = weight * EXTRA_REDUCE_PKM_WGT;
float chargeConsumed = kilometer * (BATTERY_CONSUMPTION_PKM + extraChargeConsumed);
setBatteryStatus(charge - chargeConsumed);
}

private boolean checkMaxWeight(float weight) {
if (MAX_WEIGHT < weight) {
setMessage("OverWeight");
print();
removeWeight();
return false;
}
return true;
}

private void print() {
System.out.println(isDisplay() ? "Red" : "");
System.out.println(getMessage());
checkBatteryStatus(0);
}

public void chargeRobot() throws InterruptedException {
// float currentCharge = getBatteryStatus();
// while (currentCharge <= 100) {
// Thread.sleep(500);
// System.out.println("Battery charging...");
// currentCharge += 10;
// }
// System.out.println("Robot Battery full charged");
// batteryStatus = (currentCharge > 100) ? 100 : currentCharge;
batteryStatus = 100;
}

private boolean checkBatteryStatus(float kilometer) {
System.out.println(" Current battery charge : " + getBatteryStatus());
return true;
}

public void removeWeight() {
if(getWeightCarried()==0) {
setMessage("No weight to remove");
print();
}
setWeightCarried(0);
}

public void scan(Barcode b) {
// TODO Auto-generated method stub
System.out.println();

}

}

/**
 * 
 */
package com.konzerntech.airobo.model;

/**
 * @author konzerntech
 *
 */
public class Main {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
AIRobot robo = new AIRobot();
try {
robo.chargeRobot();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// robo.carriesWeight(2f);
// robo.walk(3f);
robo.removeWeight();
robo.removeWeight();
Barcode b = new Barcode();
robo.scan(b);
robo.walkWithWeight(2f, 3f);

}

}

url : http://konzerntech.com/

Facebook comments