You are reading the article How To Use Cloudera Cdh With Different Steps? updated in November 2023 on the website Moimoishop.com. We hope that the information we have shared is helpful to you. If you find the content interesting and meaningful, please share it with your friends and continue to follow and support us for the latest updates. Suggested December 2023 How To Use Cloudera Cdh With Different Steps?
Introduction to Cloudera CDHCloudera CDH is Cloudera’s 100% open-source platform distribution provided by Cloudera Inc; it is a Palo Alto-based American Enterprise Software Company that includes Apache Hadoop, built to meet enterprise demands. Cloudera CDH delivers everything a user needs specifically for enterprise use. CDH, Cloudera Distributed Hadoop, provides the most complete, tested, and popular distribution of Apache Hadoop and other related projects. It delivers core elements of Hadoop, distributed computing, scalable storage, vital enterprise capabilities, and Web User Interface. We will explore how to use Cloudera CDH, establish its connection to Cloud Storage, and set it up.
Start Your Free Data Science Course
Hadoop, Data Science, Statistics & others
How to Use Cloudera CDH?Step 1: Before installing Cloudera Manager CDH and other managed services, the user needs to take care of Storage Space and plan for Cloudera Manager.
Cloudera Manager needs to track job metrics and applications in background processes. Storage requirements can vary depending on the organization’s size, and it can be either local, remote, or disk-based, as all the metrics require storage.
Failing to plan the storage needs, CDH can negatively impact in many ways –
A cluster might miss critical audit information not retained or gathered for the required time.
A cluster might not be able to get the historical operational data to meet internal requirements.
Gaps might be present in collections and charts.
Administrators may not have historical Yarn, MR1, or Impala data usage when they need to reference or report on it later.
Administrators may be unable to have the research health status or past data.
Configuration host in Clusters allows all the members to communicate with each other.
Setting the unique hostname
Editing /etc/hosts/ with IP address and qualified Domain name for each host in the cluster.
Editing /etc/sysconfig/network with Domain name of the host.
Verifying each host consistently identifies a network.
Firewall disabling, save the existing rule set for iptables, and then disable the firewall based on the compatibility, be it RHEL 7 and SLES or Ubuntu.
Setting Secured Enhanced Linux allows for setting the control access through policies. For example, if there is an issue in Deploying CDH, then SELinux should be set in permissive mode on every host before deploying CDH on a cluster.
Enabling NTP Service: Cloudera CDH needs Network Time Protocol(NTP) configuration on each machine in the cluster. And have the Software Collection Library Repository installed in the system.
Step 2: Connection of Cloudera Manager to Cloud Storage/ Setup Connectivity of CDH
Configuring Repository for Cloudera Manager. You install Cloudera Manager using a package tool such as zypper for SLES, yum for RHEL, and apt-get for Ubuntu.
Install JDK, Java Development Kit. It can be either Oracle JDK by Cloudera using the Cloudera Manager or an Open JDK. Most of the Linux distributions that Cloudera supports include Open JDK.
Based on the Operating system, the syntax for installing packages is as below:
sudo yum install cloudera-manager-daemons cloudera-manager-agent cloudera-manager-server à Oracle Linux, CentOS, RHEL
sudo zypper install cloudera-manager-daemons cloudera-manager-agent cloudera-manager-server à SLES
sudo apt-get install cloudera-manager-daemons cloudera-manager-agent cloudera-manager-server à Ubuntu
Installation and Configuration of Database. Cloudera uses various databases and datastore to store information about Cloudera’s configuration and the system’s health or task. Users can use MariaDB, PostgreSQL, Oracle DB, or MySQL for Cloudera Server and other services.
Setting up the Cloudera Database, Cloudera Server includes a script that helps to create and configure the database. First, the script can create a Cloudera Server Database config file. Then, create a database for the Cloudera server for usage and create and configure a user account for Cloudera Server.
After setting up the Cloudera database, you must start the Cloudera Manager Server and log in to the Admin console to install CDH and other related software. The default credentials would be admin, and the password is also admin by default.
Setting up Cluster using Wizard, after completion of adding the clusters, the installation wizard, Add Cluster Configuration Wizard, will automatically start.
Getting Started with Cloudera CDHCloudera CDH provides –
Compatibility: It leverages IT infrastructure and investment.
Flexibility: It stores any data and manipulates it with various computation frameworks that include batch processing, free text search, interactive SQL, statistical computation, and machine learning.
High Availability: It performs mission-critical business tasks with utmost confidence.
Scalability: It enables various applications that scale and extend to suit user requirements.
Security: It processes and controls sensitive data.
Cloudera CDH – Classic ClustersClassic clusters track the total number of clusters enabled for Replication Manager, track clusters in error state, active clusters, and clusters for which a warning has been issued.
Users must register on existing on-premise Cloudera Distribution of Hadoop on the Management Console, after which users can copy or move the data to the cloud. These are called classic clusters.
Classic Clusters show below statuses –
Active, Warning, Error, Total.
You must use Cloudera Manager for CDH to investigate the classic cluster’s status.
ConclusionWith this, we shall conclude the topic “Cloudera CDH.” We have seen what CDH is and how it is used, and how it is to be installed; the steps required to install and prerequisites before installation have also been looked into. We have also gone through Cloudera Connectivity to Cloud Storage or the setup of Cloudera CDH. Finally, I have gone through the Classic clusters in Cloudera CDH, which will help to give a deeper insight into the concept.
Recommended ArticlesWe hope that this EDUCBA information on “Cloudera CDH” was beneficial to you. You can view EDUCBA’s recommended articles for more information.
You're reading How To Use Cloudera Cdh With Different Steps?
How To Make Olive Juice: 15 Steps (With Pictures)
Water-cured olives can be used if you want a fresher flavor, but these olives tend to be considerably bitterer and do not last quite as long as brine-cured olives.
You could use fresh olives during harvest season, which falls out around late September through mid November, but fresh olives have a very bitter taste that may make the juice less palatable.
Dried olives should be avoided, since they do not contain enough juice to extract.
Use whole or pitted olives. Avoid olives that are stuffed with other ingredients.
Wash the olives to remove the brine. Clean the olives under running water to rinse off any brine or dirt that may be on the surface. Even though you will end up placing the olives in a salty, brine-like solution later on, it is important that you wash off any old brine to avoid contaminating the solution you use with additional salt.
Advertisement
Crushing the olives beforehand may release too much of the juice too early, causing you to lose it. If you do not pierce the olives, however, the juice may struggle to break through the skin and reach the liquid.
Mix water, salt, and vinegar in a separate bowl. Blend the ingredients together with a spoon. The liquid should have a murky appearance. If it still seems clear, you may need to add another 1 teaspoon (4.8 grams) of salt.
Pour the liquid solution into the glass jar. Do not fill the jar to the top. Instead, leave about 4 inches (10 centimeters) of empty space in between the surface of the water and the brim of the jar.
Add the twig of peppermint to the jar. Push it down so that it sits beneath the surface of the water. This step is only optional, but peppermint does add a dimension of freshness to the olive juice.
Seal and shake the jar. Make sure that the lid is securely held in place and will not loosen or come undone accidentally. Then, give the jar a vigorous shake to loosen the juice inside the olives and mix it with the other ingredients.
Place the jar of olives in the refrigerator. The juice needs time to blend into the water and other ingredients. Leave the olives inside the refrigerator for a minimum of 30 minutes or overnight.
Pour the liquid into a second, smaller glass jar. Strain out the olives and the sprig of mint. Set the olives on a glass or plastic cutting board and discard the mint.
Note that it is also important to use a plastic or glass cutting board. If you crush the olives on a wooden board, some of the juice may end up getting absorbed into the wood.
You may also find it helpful to use a plate or bowl. Many cutting boards do not have lips, so some of the juices could run off. If you crush the olives inside a bowl, however, the juices will remain.
Drain the pressed juice into the olive juice mixture. You may need to strain the juice out by scraping or dumping your pile of crushed olives into a strainer.
Seal and shake the jar of juice. Give the jar a vigorous shake to combine the new juice you added to the existing juice solution.
Store your olive juice in the refrigerator until ready to use. Shake the jar before each use to make sure that none of the ingredients have settled or separated.
Advertisement
How To Maintain Your Mobile Phone: 14 Steps (With Pictures)
If the mobile phone has sat idle for a long time, it may need special moisture treatment. In humid areas, the internal moisture of the mobile phone could cause harm to the parts. When using your mobile phone has been idle for a reasonable amount of time, it will have attained a certain internal temperature. This can cause the accumulated water to evaporate at ordinary times. To avoid harm to the body, don’t touch the antenna.
Do not attempt to open your phone. This can cause damage and can be dangerous if you do not know much about phones and how they work.
7
Maintain your mobile phone properly. If the phone or any of its parts are not working, take it to the nearest qualified maintenance facility.
Use a mobile phone holster. They can reduce the amount of wear done to the phone. Secondly, they can also reduce the harm to the phone when it gets wet.
Of course, this does not mean the holster is flame-resistant after you use it. Be cautious to avoid damaging it.
Don’t use mobile phones in the rain or the bathroom.
Don’t put your mobile phone in the cold air outlet, because condensation in the mobile phone will invisibly corrode the circuit board. The longer this goes on, the more severe the water erosion of the circuit board is. You may not notice anything initially, but if you keep going on, the phone could stop working.
Pay attention to how you carry it. Everyone has different ways to carry mobile phones, but some methods can increase the chance of damage. For example, carrying a phone in the back pocket of your jeans can cause it to fall out when you walk or be damaged if you accidentally sit on it. Also, when people keep slim phones in their breast pocket, these can fall out easily if they bend over.
Don’t put the phone near anything magnetic. The phone’s speakers contain small magnets. If a magnet becomes attracted to the speakers, it could block the sound, meaning it’s more difficult to hear.
11
Know “first aid” for your phone. It’s likely that at some point the mobile phone will come into contact with water, for example by rain or having drinks spilled on it. If this happens:
Turn off the power immediately and then, if possible, remove the battery to avoid water corroding circuit boards. Water is an enemy of your phone – after coming into contact with it, your phone should be sent for repair as soon as possible.
Do NOT use a hair dryer to dry the cell phone’s internal moisture. This may cause more harm than good. Instead, place it in a bag of uncooked rice for a day.
The power source you have plugged it into is too high and so the fuse has blown. This can be sent to a repair shop and fixed.
The battery itself is aging. This can also be sent to a repair shop and fixed,or may need replacing.
The battery has come into contact with pieces of metal with dirt, causing poor power contact and stopping it from charging. The problem is caused by oxidation of the contact terminals and as long as you use a glue stick to wipe clean, the situation will be improved.
The battery is too loose. You can put paper between the battery and the mobile phone to stop it being too loose. Do not put paper between the terminals of the battery and the phone.
If your mobile phone is lost, ask the police if anyone has found it first. If not, call your mobile phone provider and get them to lock the phone so it can’t be used for illegal activities.
Advertisement
How To Be An Eclectic Spirit: 14 Steps (With Pictures)
Have many interests. Being an eclectic spirit means having a lot of interests, or finding beauty in items/ thoughts/ experiences that are classically not appreciated. This can run the gamut. You can branch out by studying a subject that is not widely studied amongst your friends. And of that subject, be sure to dig deeply. If you are studying poetry, for example, maybe read the works by newer, or less famous, authors, too. Or perhaps you are involved in a particular activity that sets you apart from the rest, but you have to remember that you have to love this activity yourself, and you’re not just participating in it because you want to be ‘eccentric/eclectic’.
Ask yourself what you like, why you like it, what draws you to the experience or item, for example, and how to showcase it in your life. If you love writing, think of starting your own library of small works or publications of up-and-rising authors, or starting a collection of writing instruments that you can also make use of in your daily life, that you deeply appreciate. Even if you alone appreciate the items. That is the essence of eccentricity, it seems. The eccentric will act in a genuine manner – not dismayed by the actions of those around her/him. An eclectic will typically have a multitude of interests, and will be in constant reflection on these items, experiences, features of life. An eccentric eclectic will then typically have a vast and sundry array of interests, but will not camouflage/ hide her interests. She will live authentically.
Advertisement
Make contacts. Study everything. Try to see the relationships between all life, and the relationship between studies or topics that superficially seem very far removed. The way that I’ve acquired new interests, often, has been in ‘linking’ a new subject with an older subject that already fascinated me.
Do not take on an affected air. Be true to your own person. You can be highly eclectic and not dramatic. You can be eccentric in how you live – by living authentically – without acting. Eccentricity is so rare, partly, because most people are hiding who they are, or acting a role. Don’t worry about appearing more or less eccentric or eclectic. Be open to new experiences (but don’t necessarily ’embrace’ everything!) Be open to the possibility of what a new experience will bring to your life, without necessarily HAVING to engage in this new way of being. For example, if a friend wants you to try yoga, try asking yourself “why? should I? I might like it” – don’t necessarily say “no” off the hop. At the same time, if – and only after you’ve given a topic some thought – do not want to do something, don’t force yourself to do it.
Keep authentic friends about you. Know the people who you associate with – or try to get to know them. And don’t model behaviour and/or try to be like someone, no matter how clever, eclectic or ‘open’ if he/ she seems cruel or cutting. There is, for example, oftentimes huge debates over the subject of art – and what should be allowed in art, be allowed by an artist. One artist was found starving dogs for performance art. Now, despite the fact that this is a very ‘different’ way of trying to be artistic, the plain fact of the matter is that if you care AT ALL about animals, this story is horrifying. So it doesn’t matter how unique, cutting edge, etc someone/ or something is… If it doesn’t sit right in your soul, AVOID going down that path.
Know thyself, as the Delphians say. It is GREAT to develop new interests and be open to new experiences, but this doesn’t mean you have to lose yourself, or that your personality has to change. If you are introverted and often a little shy, you can try to summon up a little courage and do something differently – say, go to an art gallery opening, or breach a conversation with a friendly looking peer. This does not mean that your essence is changing. If anything, by learning new stuff, reading more and LIVING more, you are simply going to learn more about yourself, too. Maybe the truest part of chúng tôi simply hidden.
Don’t worry about fashion or trends. They change so quickly, and what makes someone else’s sense of colour/ style etc. more important – more valid – than your own?? If you love something, pursue it, and create your own fashion. A great way to do this is to go to thrift stores, and also learn how to make alterations with a sewing machine. Thrift stores carry such a wide array of styles in clothing, that you experiment. And because the prices are usually far lower – a ‘mistake’ purchase at a thrift store will cost far less than one made at a high end boutique, or even the mall.
Know that you don’t have to clash either. Also, being eclectic doesn’t mean that your style has to clash. On the contrary! The basis of eclecticism is that if something is very durable, and of high quality, well proportioned lines and a beautiful form – it will go with other well designed, beautiful items. Eclecticism doesn’t mean going for odd pieces and hoping for the best. It means being appreciative of the beauty that has existed in various forms throughout history, and not ignoring or devaluing past contributions simply because they are of the past.
Embrace your inner child. The heart of an eccentric person is childlike. Not childish. An eccentric personality will be attracted to the natural splendor, just as is a small person, a child, before he or she becomes aware that others are watching, and tries to act differently. At the heart of an eccentric being is an egoless being. This is not the same thing as having no personality. chúng tôi being egoistic – not being so full of yourself, as most adults are, that every word you speak is measured, and compared to the words of others. Or every purchase you make is with another person in mind, rather than yourself. If you are buying yourself an item of clothing – go with what you love, not what others TELL you THEY love. If someone else loves your style – terrific! That’s great. Flattering, yes? But don’t change your style to accommodate a parent, sibling, uber-controlling boyfriend etc.
If there is a character that you love, whose fashion style you love etc. – look to her as a model for ideas. This is not stealing. Very often you will find that you do not like a style of dress on your own being as much as you like it on the character. You may be totally infatuated, even, with a character and may aim to ‘change’ yourself to be more like the character. To a point, this isn’t really harmful, because if there behavior is in sync with what you love and how you’d like to be (say, more confident, or more outspoken, or more carefree etc.) then it possibly is a positive change. But remember – you don’t have to change every aspect of your behavior to have improvement. If you have traits that are holding you back, then work on those, but don’t idolize another for being ‘better’ than you. A more confident person is not better than you, simply because she or he is more confident. Everyone has problems, or areas of their life on which they need to work. No one is perfect.
Ask yourself – everyday – how something can be made better. Made truer to your own person. Take personality quizzes on-line, such as the Kiersey or the Myers Briggs Personality Inventory or the Enneagram to learn more about your personality (but remember – you are much more than a ‘type’). Look at ordinary objects in a new light. When is an old, mucky rain boot from your childhood NOT an object for the trash bin? When it can be made into a potter for vine plants! (Eccentric people were probably the first recyclers – they valued what others saw, often, as ‘junk’ and breathed new life into that which as often rejected).
Since children are often the most eccentric, and eclectic – spend extra time with your younger siblings, younger cousins etc. Read them stories, and ask them questions. Ask them all sorts of questions, and listen to their different replies. They will often provide as the muse for change in your life. If you have no young siblings, no younger cousins etc., but are a young adult – think of becoming a mentor or helping out. If you are a teen, and too young to mentor – think of volunteering at a pound or local animal shelter. Animals are very authentic beings – they do what they want, according to their personality and take on things, and can be quite healing.
Write. Write anything you want! The more you write, the more you will crave to write. Free association writing is a neat exercise you can try as well.
Make a list of simple pleasures, and try to surround yourself with ‘free beauty. A trip to the library. Changing how you take your coffee – adding brown sugar instead of Splenda, getting up early enough to see the sun rise, developing your own morning prayer or meditation ritual that only YOU know about, going to various churches or synagogues – even if you are an atheist – for a new, fresh take on being alive, watching clouds. In essence – being random!. Remember, what makes you different makes you beautiful.
Advertisement
4 Search Engines That Use Different Approaches To Achieve Relevancy
Previously here on Search Engine Journal, I covered various Semantic Search Engines which have erupted on the scene as alternatives to Google and Microsoft / Yahoo. Here are 4 more search engines that use different approaches to make results highly relevant.
1. Evrichúng tôi to put it briefly, presents to you connections between content that goes beyond keyword search. The technology powering the site is able to extract the subjects that occur in an article. This is similar to the approach that people use to understand the meaning of sentences where words and their occurrence in a sentence are used to make sense of the right context.
Taking an example from the Evri Blog,
for a sentence like:
Chief Seattle spoke to his people.
In addition, the other cool features from the site are :
EvriFeed, a constantly updating stream of the latest about interesting topics in the EvriVerse.
Evribot, an automated Twitter account that tweets extremely brief summaries of news stories.
Collections allow you to follow entities for latest updates on them.
APIs to make these entity extraction available to Developers
There is an iphone app as well.
Using semantic technologies, Evri is able to search, relate and suggest information beyond the limits of keyword matching. Perhaps the icing on the cake would be providing completely crafted articles that get their information from the ever growing content on the web, but are not being heavily dependent on any single source alone.
2. DuckDuckGoThere is a firefox extension for the engine that saves you from useless, parked and spam pages from search results, They have an iPhone app as well.
On DuckDuckGo
3. DeepDyveDeepDyve is a research tool that retrieves content from the ‘Deep Web‘. By applying semantics to a data source not indexed by traditional search engines, the engine has a good chance of returning very relevant data. For now, the engine is limited to these areas :
Life Sciences and Medical
Physical Sciences
Humanities and Social Sciences
Business and Finance
Patents, Legal
Clean Technology and Energy
IT and Engineering.
If you need specific information in any of these areas, you must try DeepDyve.
Deepdyve Sources
4. TruevertTruevert claims a semantic model that is not dependent on categorization alone. While the engine presently serves content in context of the environment, the idea is to have a model created for different contexts that a keyword can map to. Their blog provides good information on semantic search and the different approaches. The contextual model makes for highly scalable and quick response times.
How To Use Java Serversocket With Examples
Introduction to Java ServerSocket
The following article provides an outline on Java ServerSocket. In web technology, we have used front end and backend codes separately for creating web applications for the secure chúng tôi web application contains servers for receiving the client request and sent to the response for the clients’ particular request. In java technology, with the help of socket programs, we can achieve these tasks when we will send multiple requests with the help of multiple pcs, which has to be connected with the protocols like tcp and udp. We can write the server codes like ServerSocket class, connect with the specified ports, and send them to the data.
Start Your Free Software Development Course
Syntax:
The serversocket class is used for the client and server transfer process.
Server Class:
java packages import(import java.io.*,import java.net.*) class serverclassname { public static void main(String[] args) { try { --some logic— } catch() { } } }Client class:
Java packages import(import java.io.*,import java.net.*) class clientclassname { public static void main(String[] args) { try { --some logic— } catch() { } } } How to use Java ServerSocket?
Java server socket connections will use the two types of protocols for sent and receive the data.
TCP(transfer control protocol) and udp(user datagram protocol) will use the sockets class to transfer the data.
We also see some difference between these two protocols while we use in the socket class when we use udp, it means is a connection less, and there are no sessions for storing the log data regarding client and server transmissions, but in tcp, it is a connection-oriented, so the client and server have the session storages in the log folders.
The socket programs will be used for communications between the web applications running with the different jre.
The serversocket class are mainly with the connection-oriented socket programs.
When we connect the applications with the help of socket, we need to get the information’s like IP Address of the servers and port numbers which has to be connected with the applications for a specified way so that the data transmission will not be interpreted.
Basically, the socket class between client and server is one-way data transmission. The client will send the request messages to the server, servers read the client messages, and send the response to the client, or else it will display the data on the client screen like browsers.
So that we will use two types of java net classes are used a socket and serversocket classes; the socket class is responsible for client-server communications, serversocket class is used for server-side applications it will authenticate the request from the client-side until the client machine is connected with the socket class after the successful connections it will return the socket class instance in the server-side applications.
Examples of Java ServerSocketGiven below are the examples:
Example #1Code: Client Example
import java.io.IOException; import java.io.PrintStream; import java.net.Socket; import java.net.UnknownHostException; import java.util.Scanner; public class clientSample { public static void main(String arg[]) throws UnknownHostException,IOException { int n,n1; String s; Scanner sc=new Scanner(System.in); Socket s1=new Socket("127.0.0.1",1408); Scanner sc1=new Scanner(s1.getInputStream()); System.out.println("Enter any port numbers"); n=sc.nextInt(); PrintStream p=new PrintStream(s1.getOutputStream()); p.println(n); n1=sc1.nextInt(); System.out.println("Square of the given port number is: "+n1); } }Output:
import java.io.IOException; import java.io.PrintStream; import java.net.ServerSocket; import java.net.Socket; import java.net.UnknownHostException; import java.util.Scanner; public class ServerSample { public static void main(String[] args)throws IOException { int n,n1; String s; ServerSocket s1=new ServerSocket(1408); Socket s2=s1.accept(); Scanner sc=new Scanner(s2.getInputStream()); s=s2.toString(); n =sc.nextInt(); n1=n*n; PrintStream p=new PrintStream(s2.getOutputStream()); p.println(n1); System.out.println("Server started and working.. "); } }Output:
Example #2Code: Client Example
import java.net.*; import java.io.*; public class clientSample { public static void main(String[] args) throws Exception { try{ Socket s=new Socket("127.0.0.1",8888); DataInputStream d=new DataInputStream(s.getInputStream()); DataOutputStream out=new DataOutputStream(s.getOutputStream()); BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String client="",server=""; while(!client.equals("")){ System.out.println("Enter the number :"); client=br.readLine(); out.writeUTF(client); out.flush(); server=d.readUTF(); System.out.println(server); } out.close(); out.close(); s.close(); }catch(Exception e){ System.out.println(e); } } }Code: Server Client
import java.io.DataInputStream; import java.io.DataOutputStream; import java.net.Socket; class ServerClients extends Thread { Socket sockets; int clients; int squre; ServerClients(Socket s,int count){ sockets = s; clients=count; } public void run(){ try{ DataInputStream inStream = new DataInputStream(sockets.getInputStream()); DataOutputStream outStream = new DataOutputStream(sockets.getOutputStream()); String client="", server=""; while(!client.equals("")){ client=inStream.readUTF(); System.out.println("From Client side-" +clients+ ": Number of client is :"+client); squre = Integer.parseInt(client) * Integer.parseInt(client); server="From Server to Client request-" + clients + " Square of the client " + client + " is " +squre; outStream.writeUTF(server); outStream.flush(); } inStream.close(); outStream.close(); sockets.close(); }catch(Exception ex){ System.out.println(ex); }finally{ System.out.println("Client -" + clients + " exit!! "); } } }Code: Server Example
import java.net.*; import java.io.*; public class ServerSample { public static void main(String[] args) throws Exception { try{ ServerSocket s=new ServerSocket(8888); int count=0; System.out.println("Server is Started ...."); while(true){ count++; Socket socket=s.accept(); ServerClients sc = new ServerClients(socket,count); sc.start(); } }catch(Exception e){ System.out.println(e); } } }Output:
Example #3Code: Client Program
import java.net.*; import java.io.*; public class ClientMain { public static void main (String[] args ) throws IOException { int size=1022388; int bytess; int c = 0; Socket sockets = new Socket("localhost",12345); byte [] bytes = new byte [size]; InputStream in = sockets.getInputStream(); FileOutputStream out = new FileOutputStream("F:\copy.doc"); BufferedOutputStream b = new BufferedOutputStream(out); bytess= in.read(bytes,0,bytes.length); c = bytess; do { bytess = in.read(bytes, c, (bytes.length-c)); } b.write(bytes, 0 , c); b.flush(); b.close(); sockets.close(); } }Code: Server Program
import java.net.*; import java.io.*; public class Main { public static void main (String [] args ) throws IOException { ServerSocket serverSockets = new ServerSocket(12345); Socket sockets = serverSockets.accept(); System.out.println("Server connection Accepted : " + sockets); File f = new File ("F:\Sample.docx"); byte [] bytes = new byte [(int)f.length()]; FileInputStream input = new FileInputStream(f); BufferedInputStream b = new BufferedInputStream(input); b.read(bytes,0,bytes.length); OutputStream output = sockets.getOutputStream(); System.out.println("Sending Files..."); output.write(bytes,0,bytes.length); output.flush(); sockets.close(); System.out.println("File transfer complete"); } }Output:
ConclusionIn java programming technology, the package is called java.net.* In that each version of java it may vary the classes in the package the server socket connection is a basic networking feature for file transmission, upload and even though we have sent an email from one client to another client with the help of socket connections
Recommended Articles
This is a guide to Java ServerSocket. Here we discuss the introduction, how to use Java ServerSocket, along with respective examples. You may also have a look at the following articles to learn more –
Update the detailed information about How To Use Cloudera Cdh With Different Steps? on the Moimoishop.com website. We hope the article's content will meet your needs, and we will regularly update the information to provide you with the fastest and most accurate information. Have a great day!