Categories
Linux

Usage of Pipe (|) commad in Linux

Pipe command redirects the output of one command to input to another command.  That means helpful when we want output of one command to input put to the another command.  Pipe command represent symbol as |. For Example, a file contains list of 1 to 1000 numbers, lets use cat command to display name. But […]

Categories
Java Programming

Copy the file from the large file

Create the new file from large file, using File Channel and ByteBuffer: Example :  import java.io.IOException; import java.net.URI; import java.nio.ByteBuffer; import java.nio.channels.FileChannel; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardOpenOption; import java.util.Date; public class CopyLargeFileExample { public static void main(String args[]) throws IOException { long startTime = new Date().getTime(); // args[0] — Input source file // args[1] […]

Categories
How Linux

How to do tunnel the IP and Port through SSH connection using putty client software

We can do tunneling the IP and Port through SSH connection using putty software very easily. To do tunnel below points are mandatory: You should have access to server which you want to tunnel. From the your access machine , you should have access to destination IP and port. Port forward should be enabled in […]

Categories
Java Programming

Java NIO : write small size file using FileChannel

Write the file Using ByteBuffer and FileChannel from String: import java.io.IOException; import java.net.URI; import java.nio.ByteBuffer; import java.nio.channels.FileChannel; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardOpenOption; public class WriteFileUsingFileChannel { public static void main(String args[]) throws IOException { String content = “Text content”; Path file = Paths.get(URI.create(“file:///D:/TestFile.txt”)); FileChannel fileChannel = FileChannel.open(file, StandardOpenOption.CREATE, StandardOpenOption.WRITE); ByteBuffer buffer = ByteBuffer.allocate(content.length()); buffer.put(content.getBytes()); […]

Categories
Java Programming

Java NIO : read small size file using FileChannel

Read the file Using ByteBuffer and file Size: import java.io.IOException; import java.nio.ByteBuffer; import java.nio.channels.FileChannel; import java.nio.file.Path; import java.nio.file.Paths; public class ReadFileUsingFileChannel { public static void main(String args[]) throws IOException { String inputFile = “D:\\SampleFile.txt”; //Set the Path with input file Path file = Paths.get(inputFile); //Open the file FileChannel fileChannel = FileChannel.open(file); //Get the Size of […]

Categories
Linux

How to change the hostname in Linux

This article describes the how the change the hostname in Linux machine. Let’s start. Open the network file. # sudo vi /etc/sysconfig/network Modify the HOSTNAME= value with your domain name. Example hostname is “myhostname” HOSTNAME = myhostname To access with in the server add it in /etc/hosts file 127.0.0.1 myhostname Run the “hostname” command. This command […]

Categories
Linux

Linux – grep command hacks

grep command print lines matching a pattern. grep is a powerful command for file searching text. here the real-time use full command hacks. The example is the sample file and data. # cat > testfile one two three four five six seven eight nine ten Search string in a file Syntax: grep ‘string’ filename Example: […]

Categories
Database Java Programming JDBC

JDBC Architecture

Java Architecture is consist of Java Application, JDBC API, DriverManager, Driver and Database. Java Application is our client program which contains JDBC API client logic and our bussiness logic. JDBC API: JDBC ( Java Database Connectivity) API  provides the connectivity between Java application and Database. Java application can communicate with any Database with the help […]

Categories
Networking NGINX What

What is Reverse proxy and configure NGINX as a reverse proxy

What is Reverse Proxy:  Reverse proxy takes the request from the client over the network, forward to the server in an internal server and send back server’s response to the client. The advantage of Reverse proxy: The reverse proxy hides the existence and characteristics of the server. Reverse proxy protects the server from web-based attacks, DOS […]