Check the Operating System – Java Utility

public class SystemUtility {

private static String OS = System.getProperty(“os.name”).toLowerCase();

/**
* If System is Windows OS
* @return
*/
public static boolean isWindows() {

return (OS.indexOf(“win”) >= 0);

}

/**
* If System OS is Mac
* @return
*/
public static boolean isMac() {

return (OS.indexOf(“mac”) >= 0);

}

/**
* If System OS is Linux/Unix
* @return
*/
public static boolean isUnix() {

return (OS.indexOf(“nix”) >= 0 || OS.indexOf(“nux”) >= 0 || OS.indexOf(“aix”) > 0 );

}

/**
* If System OS is Solaries
* @return
*/
public static boolean isSolaris() {

return (OS.indexOf(“sunos”) >= 0);

}

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
if (isWindows()) {
System.out.println(“This is Windows”);
} else if (isMac()) {
System.out.println(“This is Mac”);
} else if (isUnix()) {
System.out.println(“This is Unix or Linux”);
} else if (isSolaris()) {
System.out.println(“This is Solaris”);
} else {
System.out.println(“Your OS is not support!!”);
}
}
}

Advertisements
| Leave a comment

Compare two table columns attributes data – Using SQL Queries

/**
* Create Source table for Compare CSV Files Data
* @param filePath
* @param conn
* @param chunkId
* @param subsetId
* @throws Exception
*/
public void getFileContentSRC(String filePath,Connection conn,String chunkId,String subsetId) throws Exception
{
String sql=””;
CSVParser parser = new CSVParser(new FileReader(filePath), CSVFormat.DEFAULT.withSkipHeaderRecord());

/*sql = “BEGIN EXECUTE IMMEDIATE ‘DROP TABLE ZZ_COMPARE_CSV_SRC’;EXCEPTION WHEN OTHERS THEN NULL;END; “;
ps = conn.prepareStatement(sql);
ps.executeUpdate(sql);*/

sql = “CREATE TABLE ZZ_COMPARE_CSV_SRC_”+chunkId+”_”+subsetId+”(MSISDN VARCHAR2(20)) ” ;
try(PreparedStatement ps = conn.prepareStatement(sql)){
ps.executeUpdate(sql);
}
sql = “INSERT INTO ZZ_COMPARE_CSV_SRC_”+chunkId+”_”+subsetId+”(MSISDN) VALUES (?)”;
try(PreparedStatement ps = conn.prepareStatement(sql)){
final int batchSize = 1000;
int count = 0;

for (CSVRecord record : parser) {
ps.setString(1, record.get(0));
ps.addBatch();

if(++count % batchSize == 0) {
ps.executeBatch();
}
}
parser.close();
ps.executeBatch(); // insert remaining records
ps.close();
//conn.close();
}
}
/**
* Create Destination Table for Compare CSV files Data
* @param filePath
* @param conn
* @param chunkId
* @param subsetId
* @throws Exception
*/
public void getFileContentDST(String filePath,Connection conn,String chunkId,String subsetId) throws Exception
{
String sql=””;
CSVParser parser = new CSVParser(new FileReader(filePath), CSVFormat.DEFAULT.withSkipHeaderRecord());

/*sql = “BEGIN EXECUTE IMMEDIATE ‘DROP TABLE ZZ_COMPARE_CSV_DST’;EXCEPTION WHEN OTHERS THEN NULL;END; “;
ps = conn.prepareStatement(sql);
ps.executeUpdate(sql);*/

sql = “CREATE TABLE ZZ_COMPARE_CSV_DST_”+chunkId+”_”+subsetId+”(MSISDN VARCHAR2(20)) ” ;
try(PreparedStatement ps = conn.prepareStatement(sql)){
ps.executeUpdate(sql);
}

sql = “INSERT INTO ZZ_COMPARE_CSV_DST_”+chunkId+”_”+subsetId+”(MSISDN) VALUES (?)”;
try(PreparedStatement ps = conn.prepareStatement(sql)){
final int batchSize = 1000;
int count = 0;

for (CSVRecord record : parser) {
ps.setString(1, record.get(0));
ps.addBatch();

if(++count % batchSize == 0) {
ps.executeBatch();
}
}
parser.close();
ps.executeBatch(); // insert remaining records*/
ps.close();
}
//conn.close();
}

/**
* Generate Log Files
* @param filePath
* @param conn
* @throws Exception
*/
public void generateLogFiles(String filePath,Connection conn,String chunkId,String subsetId) throws Exception
{
//Statement ps=null;
String sql=””;
ResultSet resultSet = null;
sql = “SELECT ROWNUM AS ROWNR,’OK’ AS STATUS,S.MSISDN FROM ZZ_COMPARE_CSV_SRC_”+chunkId+”_”+subsetId+” S,ZZ_COMPARE_CSV_DST_”+chunkId+”_”+subsetId+” D WHERE S.MSISDN=D.MSISDN ORDER BY ROWNR “;
try(Statement ps = conn.createStatement()){
resultSet = ps.executeQuery(sql);
ResultSetMetaData meta = resultSet.getMetaData() ;
int numberOfColumns = meta.getColumnCount() ;
String dataHeaders = “” + meta.getColumnName(1) + “” ;
for (int i = 2 ; i < numberOfColumns + 1 ; i ++ ) {
dataHeaders += “,” + meta.getColumnName(i) + “” ;
}
String[] tableHeader = dataHeaders.split(“,”) ;
CSVFormat format = CSVFormat.DEFAULT.withRecordSeparator(“\n”);
String[] headers = format.getHeader();
String FILE_NAME = filePath;
File file = new File(FILE_NAME);
FileWriter fw = new FileWriter(file);
CSVPrinter printer = new CSVPrinter(fw, format.withFirstRecordAsHeader());
for (int i = 0; i < tableHeader.length; i++) {
printer.print(tableHeader[i]);
}
printer.println();
printer.printRecords(resultSet);
fw.close();
printer.close();
}
//conn.close();
}

/**
* Generate Bad Files
* @param filePath
* @param conn
* @throws Exception
*/
public void generateBadFiles(String filePath,Connection conn,String chunkId,String subsetId) throws Exception
{
String sql=””;
ResultSet resultSet = null;
sql = “SELECT ROWNUM AS ROWNR,’2627′ AS ERROR_CODE,’NOT_LOADED’ AS ERROR_REASON,MSISDN FROM ZZ_COMPARE_CSV_SRC_”+chunkId+”_”+subsetId+” WHERE MSISDN NOT IN (SELECT MSISDN FROM ZZ_COMPARE_CSV_DST_”+chunkId+”_”+subsetId+”) ORDER BY ROWNR”;
try(Statement ps = conn.createStatement()){
resultSet = ps.executeQuery(sql);
ResultSetMetaData meta = resultSet.getMetaData() ;
int numberOfColumns = meta.getColumnCount() ;
String dataHeaders = “” + meta.getColumnName(1) + “” ;
for (int i = 2 ; i < numberOfColumns + 1 ; i ++ ) {
dataHeaders += “,” + meta.getColumnName(i) + “” ;
}
String[] tableHeader = dataHeaders.split(“,”) ;
CSVFormat format = CSVFormat.DEFAULT.withRecordSeparator(“\n”);
String[] headers = format.getHeader();
String FILE_NAME = filePath;
File file = new File(FILE_NAME);
FileWriter fw = new FileWriter(file);
CSVPrinter printer = new CSVPrinter(fw, format.withFirstRecordAsHeader());
for (int i = 0; i < tableHeader.length; i++) {
printer.print(tableHeader[i]);
}
printer.println();
printer.printRecords(resultSet);
fw.close();
printer.close();
//conn.close();
}
}

/**
* This will drop the compare tables Source and Destination tables
* @param conn
* @param chunkId
* @param subsetId
* @throws Exception
*/
public void dropComparisonTables(Connection conn,String chunkId,String subsetId) throws Exception
{

String sqlSource=””;
String sqlDestination=””;

sqlSource = “BEGIN EXECUTE IMMEDIATE ‘DROP TABLE ZZ_COMPARE_CSV_SRC_”+chunkId+”_”+subsetId+”‘;EXCEPTION WHEN OTHERS THEN NULL;END; “;
try(PreparedStatement psSource = conn.prepareStatement(sqlSource)){
psSource.executeUpdate(sqlSource);
}

sqlDestination = “BEGIN EXECUTE IMMEDIATE ‘DROP TABLE ZZ_COMPARE_CSV_DST_”+chunkId+”_”+subsetId+”‘;EXCEPTION WHEN OTHERS THEN NULL;END; “;
try(PreparedStatement psDestination = conn.prepareStatement(sqlDestination)){
psDestination.executeUpdate(sqlDestination);
}
//conn.close();
}

| Leave a comment

Get the common files names in 2 different directories – Java Utility

/**
* This will return common file names from the List
* @param localListOfFiles
* @param sdpListOfFiles
* @return
*/
public static List getCommonFileNames(File[] localListOfFiles,File[] sdpListOfFiles)
{
List<String> commonFiles=new ArrayList<String>();
for (int j = 0; j < localListOfFiles.length; j++) {
for (int k = 0; k < sdpListOfFiles.length; k++) {
//System.out.println(“File ” + localListOfFiles[i].getName());
String localName = localListOfFiles[j].getName();
String sdpName= sdpListOfFiles[k].getName();
if(localName.equalsIgnoreCase(sdpName))
{
commonFiles.add(localName);
}
}
}
return commonFiles;
}

| Leave a comment

Get the Latest Files from the Particular Directory – Java Utility

/**
* This can get the Latest file from the Directory
* @param dirPath
* @return
*/
public String getLatestFilefromDir(String dirPath){
File dir = new File(dirPath);
File[] files = dir.listFiles();
if (files == null || files.length == 0) {
return null;
}

File lastModifiedFile = files[0];
for (int i = 1; i < files.length; i++) {
if (lastModifiedFile.lastModified() < files[i].lastModified()) {
lastModifiedFile = files[i];
}
}
return lastModifiedFile.getName().toString();
}

| Leave a comment

File Transfer Check – MD5 Checksum Java Utility

import java.io.FileInputStream;
import java.security.MessageDigest;

public class MD5CheckSumUtility
{
/**
* This will check the MD5 Checking
* @param fileInput
* @return
* @throws Exception
*/
public String checkMD5(String fileInput)throws Exception
{
MessageDigest md = MessageDigest.getInstance(“MD5”);
FileInputStream fis = new FileInputStream(fileInput);
String result = “”;
byte[] dataBytes = new byte[1024];

int nread = 0;
while ((nread = fis.read(dataBytes)) != -1) {
md.update(dataBytes, 0, nread);
};
byte[] mdbytes = md.digest();

//convert the byte to hex format method 1
StringBuffer sb = new StringBuffer();
for (int i = 0; i < mdbytes.length; i++) {
sb.append(Integer.toString((mdbytes[i] & 0xff) + 0x100, 16).substring(1));
}
//System.out.println(“Digest(in hex format):: ” + sb.toString());
//convert the byte to hex format method 2
StringBuffer hexString = new StringBuffer();
for (int i=0;i<mdbytes.length;i++) {
String hex=Integer.toHexString(0xff & mdbytes[i]);
if(hex.length()==1) hexString.append(‘0’);
hexString.append(hex);
}
//System.out.println(“Digest(in hex format):: ” + hexString.toString());
result = hexString.toString();
return result;
}

}

| Leave a comment

Compare Column/Attribute Data – Using Java Set Operations

/**
* This will return all Elements in Both the CSV files
* @param coll1
* @param coll2
* @return
*/
public static Collection union(Collection coll1, Collection coll2) {
Set union = new TreeSet(coll1);
union.addAll(new TreeSet(coll2));
return union;
}

/**
* This will return the common elements in both sets
* @param coll1
* @param coll2
* @return
*/
public static Collection intersect(Collection coll1, Collection coll2) {
Set intersection = new TreeSet(coll1);
intersection.retainAll(new TreeSet(coll2));
return intersection;
}

/**
* This will return Non overlap elements in Set 2
* @param coll1
* @param coll2
* @return
*/
public static Collection nonOverLap(Collection coll1, Collection coll2) {
Collection result = union(coll1, coll2);
result.removeAll(intersect(coll1, coll2));
return result;
}

/**
* This will return the left table uncommon elements
* @param coll1
* @param coll2
* @return
*/
public static Collection leftjoin(Collection coll1, Collection coll2) {
Collection intersect = intersect(coll1, coll2);
coll1.removeAll(intersect);
return coll1;
}

| Leave a comment

Telecom – 5G Revolution By Ericsson

5G is the Fifth Generation technology. It has many advanced features potential enough to solve many of the problems of our mundane life. It is beneficial for the government, as it can make the governance easier; for the students, as it can make available the advanced courses, classes, and materials online; it is easier for the common people as well, as it can facilitate them the internet everywhere. So, this tutorial is divided into various chapters and describes the 5G technology, its applications, challenges, etc., in detail.

Radio technologies have evidenced a rapid and multidirectional evolution with the launch of the analogue cellular systems in 1980s. Thereafter, digital wireless communication systems are consistently on a mission to fulfil the growing need of human beings (1G, …4G, or now 5G).

5G Technology

So, this article describes the 5G technology emphasizing on its salient features, technological design (architecture), advantages, shortcomings, challenges, and future scope.

Salient Features of 5G

5th Generation Mobile Network or simply 5G is the forthcoming revolution of mobile technology. The features and its usability are much beyond the expectation of a normal human being. With its ultra-high speed, it is potential enough to change the meaning of a cell phone usability.

Salient Features of 5G

With a huge array of innovative features, now your smart phone would be more parallel to the laptop. You can use broadband internet connection; other significant features that fascinate people are more gaming options, wider multimedia options, connectivity everywhere, zero latency, faster response time, and high quality sound and HD video can be transferred on other cell phone without compromising with the quality of audio and video

If we look back, we will find that every next decade, one generation is advancing in the field of mobile technology. Starting from the First Generation (1G) in 1980s, Second Generation (2G) in 1990s, Third Generation (3G) in 2000s, Fourth Generation (4G) in 2010s, and now Fifth Generation (5G), we are advancing towards more and more sophisticated and smarter technology.

Smarter Technology

What is 5G Technology?

The 5G technology is expected to provide a new (much wider than the previous one) frequency bands along with the wider spectral bandwidth per frequency channel. As of now, the predecessors (generations) mobile technologies have evidenced substantial increase in peak bitrate. Then — how is 5G different from the previous one (especially 4G)? The answer is — it is not only the increase in bitrate made 5G distinct from the 4G, but rather 5G is also advanced in terms of −

  • High increased peak bit rate
  • Larger data volume per unit area (i.e. high system spectral efficiency)
  • High capacity to allow more devices connectivity concurrently and instantaneously
  • Lower battery consumption
  • Better connectivity irrespective of the geographic region, in which you are
  • Larger number of supporting devices
  • Lower cost of infrastructural development
  • Higher reliability of the communications

As researchers say, with the wide range of bandwidth radio channels, it is able to support the speed up to 10 Gbps, the 5G WiFi technology will offer contiguous and consistent coverage − “wider area mobility in true sense.”

Architecture of 5G is highly advanced, its network elements and various terminals are characteristically upgraded to afford a new situation. Likewise, service providers can implement the advance technology to adopt the value-added services easily.

However, upgradeability is based upon cognitive radio technology that includes various significant features such as ability of devices to identify their geographical location as well as weather, temperature, etc. Cognitive radio technology acts as a transceiver (beam) that perceptively can catch and respond radio signals in its operating environment. Further, it promptly distinguishes the changes in its environment and hence respond accordingly to provide uninterrupted quality service.

Architecture of 5G

As shown in the following image, the system model of 5G is entirely IP based model designed for the wireless and mobile networks.

5G Architecture

The system comprising of a main user terminal and then a number of independent and autonomous radio access technologies. Each of the radio technologies is considered as the IP link for the outside internet world. The IP technology is designed exclusively to ensure sufficient control data for appropriate routing of IP packets related to a certain application connections i.e. sessions between client applications and servers somewhere on the Internet. Moreover, to make accessible routing of packets should be fixed in accordance with the given policies of the user (as shown in the image given below).

5G Architecture1

The Master Core Technology

As shown in the Figure 5, the 5G MasterCore is convergence point for the other technologies, which have their own impact on existing wireless network. Interestingly, its design facilitates MasterCore to get operated into parallel multimode including all IP network mode and 5G network mode. In this mode (as shown in the image given below), it controls all network technologies of RAN and Different Access Networks (DAT). Since, the technology is compatible and manages all the new deployments (based on 5G), it is more efficient, less complicated, and more powerful.

Master Core Technology

Surprisingly, any service mode can be opened under 5G New Deployment Mode as World Combination Service Mode (WCSM). WCSM is a wonderful feature of this technology; for example, if a professor writes on the white board in a country – it can be displayed on another white board in any other part of the world besides conversation and video. Further, a new services can be easily added through parallel multimode service.

Normally, it is expected that the time period required for the 5G technology development and its implementation is about five years more from now (by 2020). But to becoming usable for the common people in developing countries, it could be even more.

Time Period Required

Graph 1 − Showing the Timeline of all previous generation technologies.

Expected Time Length

By considering the multiple utility and various fashionable salient features, researchers are anticipating that this technology will be in use until 2040s.

G technology is adorned with many as well as distinct features, which applicability is useful for a wide range people irrespective of their purposes (as shown in the mweb image).

Applications

Applications of 5G

Some of the significant applications are −

  • It will make unified global standard for all.
  • Network availability will be everywhere and will facilitate people to use their computer and such kind of mobile devices anywhere anytime.
  • Because of the IPv6 technology, visiting care of mobile IP address will be assigned as per the connected network and geographical position.
  • Its application will make world real Wi Fi zone.
  • Its cognitive radio technology will facilitate different version of radio technologies to share the same spectrum efficiently.
  • Its application will facilitate people to avail radio signal at higher altitude as well.

    Application of 5G is very much equivalent to accomplishment of dream. It is integrated with beyond the limit advance features in comparison to the previous technologies.

    Advancement

    Advanced Features

    In comparison to previous radio technologies, 5G has following advancement −

    • Practically possible to avail the super speed i.e. 1 to 10 Gbps.
    • Latency will be 1 millisecond (end-to-end round trip).
    • 1,000x bandwidth per unit area.
    • Feasibility to connect 10 to 100 number of devices.
    • Worldwide coverage.
    • About 90% reduction in network energy usage.
    • Battery life will be much longer.
    • Whole world will be in wi fi zone.

    5G – Advantages & Disadvantages

    5th generation technology offers a wide range of features, which are beneficial for all group of people including, students, professionals (doctors, engineers, teachers, governing bodies, administrative bodies, etc.) and even for a common man.

    Ericsson

    Important Advantages

    There are several advantages of 5G technology, some of the advantages have been shown in the above Ericsson image, and many others are described below −

    • High resolution and bi-directional large bandwidth shaping.
    • Technology to gather all networks on one platform.
    • More effective and efficient.
    • Technology to facilitate subscriber supervision tools for the quick action.
    • Most likely, will provide a huge broadcasting data (in Gigabit), which will support more than 60,000 connections.
    • Easily manageable with the previous generations.
    • Technological sound to support heterogeneous services (including private network).
    • Possible to provide uniform, uninterrupted, and consistent connectivity across the world.
    Some Other Advantages for the Common People
    Parallel multiple services, such as you can know weather and location while talking with other person.
    You can control your PCs by handsets.
    Education will become easier − A student sitting in any part of world can attend the class.
    Medical Treatment will become easier & frugal − A doctor can treat the patient located in remote part of the world.
    Monitoring will be easier − A governmental organization and investigating offers can monitor any part of the world. Possible to reduce the crime rate.
    Visualizing universe, galaxies, and planets will be possible.
    Possible to locate and search the missing person.
    Possible, natural disaster including tsunami, earthquake etc. can be detected faster.

    Disadvantages of 5G Technology

    Though, 5G technology is researched and conceptualized to solve all radio signal problems and hardship of mobile world, but because of some security reason and lack of technological advancement in most of the geographic regions, it has following shortcomings −

    • Technology is still under process and research on its viability is going on.
    • The speed, this technology is claiming seems difficult to achieve (in future, it might be) because of the incompetent technological support in most parts of the world.

    Disadvantages

    • Many of the old devices would not be competent to 5G, hence, all of them need to be replaced with new one — expensive deal.
    • Developing infrastructure needs high cost.
    • Security and privacy issue yet to be solved.

      Challenges are the inherent part of the new development; so, like all technologies, 5G has also big challenges to deal with. As we see past i.e. development of radio technology, we find very fast growth. Starting from 1G to 5G, the journey is merely of about 40 years old (Considering 1G in 1980s and 5G in 2020s). However, in this journey, the common challenges that we observed are lack of infrastructure, research methodology, and cost.

      ChallengesStill, there are dozens of countries using 2G and 3G technologies and don’t know even about 4G, in such a condition, the most significant questions in everyone’s mind are −

      • How far will 5G be viable?
      • Will it be the technology of some of the developed countries or developing countries will also get benefit of this?

      To understand these questions, the challenges of 5G are categorized into the following two headings −

      • Technological Challenges
      • Common Challenges

      Technological Challenges

      • Inter-cell Interference − This is one of the major technological issues that need to be solved. There is variations in size of traditional macro cells and concurrent small cells that will lead to interference.

      Technological Challenges

      • Efficient Medium Access Control − In a situation, where dense deployment of access points and user terminals are required, the user throughput will be low, latency will be high, and hotspots will not be competent to cellular technology to provide high throughput. It needs to be researched properly to optimize the technology.
      • Traffic Management − In comparison to the traditional human to human traffic in cellular networks, a great number of Machine to Machine (M2M) devices in a cell may cause serious system challenges i.e. radio access network (RAN) challenges, which will cause overload and congestion.

      Common Challenges

      • Multiple Services − Unlike other radio signal services, 5G would have a huge task to offer services to heterogeneous networks, technologies, and devices operating in different geographic regions. So, the challenge is of standardization to provide dynamic, universal, user-centric, and data-rich wireless services to fulfil the high expectation of people.

      Common Challenges

      • Infrastructure − Researchers are facing technological challenges of standardization and application of 5G services.
      • Communication, Navigation, & Sensing − These services largely depend upon the availability of radio spectrum, through which signals are transmitted. Though 5G technology has strong computational power to process the huge volume of data coming from different and distinct sources, but it needs larger infrastructure support.
      • Security and Privacy − This is one of the most important challenges that 5G needs to ensure the protection of personal data. 5G will have to define the uncertainties related to security threats including trust, privacy, cybersecurity, which are growing across the globe.
      • Legislation of Cyberlaw − Cybercrime and other fraud may also increase with the high speed and ubiquitous 5G technology. Therefore, legislation of the Cyberlaw is also an imperative issue, which largely is governmental and political (national as well as international issue) in nature.

        Several researches and discussions are going on across the world among technologists, researchers, academicians, vendors, operators, and governments about the innovations, implementation, viability, and security concerns of 5G.

        As proposed, loaded with multiple advance features starting from the super high speed internet service to smooth ubiquitous service, 5G will unlock many of the problems. However, the question is — in a situation, where the previous technologies (4G and 3G) are still under process and in many parts yet to be started; what will be the future of 5G?

        Future Scope5th generation technology is designed to provide incredible and remarkable data capabilities, unhindered call volumes, and immeasurable data broadcast within the latest mobile operating system. Hence, it is more intelligent technology, which will interconnect the entire world without limits. Likewise, our world would have universal and uninterrupted access to information, communication, and entertainment that will open a new dimension to our lives and will change our life style meaningfully.

        Moreover, governments and regulators can use this technology as an opportunity for the good governance and can create healthier environments, which will definitely encourage continuing investment in 5G, the next generation technology.

| Leave a comment