Home » Core Java » apache » commons » Page 4

commons

Get list of files from FTP Server

In this example we shall show you how to get a list of files from an FTP Server. We are using the org.apache.commons.net.ftp.FTPClient Class that encapsulates all the functionality necessary to store and retrieve files from an FTP server. To get a list of files from an FTP Server one should perform the following steps: Create a new FTPClient. Use connect() API ...

Read More »

Establish connection with FTP Server

With this example we are going to demonstrate how to establish a connection with an FTP Server. We are using the org.apache.commons.net.ftp.FTPClient Class that encapsulates all the functionality necessary to store and retrieve files from an FTP server. In short, to establish a connection with an FTP Server you should: Create a new FTPClient. Use connect() API method to open a ...

Read More »

Download file from FTP Server

This is an example of how to download a File from an FTP Server, using the org.apache.commons.net.ftp.FTPClient Class, that encapsulates all the functionality necessary to store and retrieve files from an FTP server. Downloading a File from an FTP Server implies that you should: Create a new FTPClient. Use connect() API method to open a connection to the FTP Server. ...

Read More »

File Upload to FTP Server

In this example we shall show you how to upload a File to an FTP Server, using the org.apache.commons.net.ftp.FTPClient Class, that encapsulates all the functionality necessary to store and retrieve files from an FTP server. To upload a File to an FTP Server one should perform the following steps: Create a new FTPClient. Use connect() API method to open a connection ...

Read More »

Check if Days and Calendars match

With this example we are going to demonstrate how to check if Days and Calendars match. We are using the org.apache.commons.lang3.time.DateUtils Class, that is a suite of utilities surrounding the use of the Calendar and Date object. DateUtils contains a lot of common methods considering manipulations of Dates or Calendars. In short, to check if Days and Calendars match you should: ...

Read More »

Capitalize words of a string

This is an example of how to capitalize the words of a String. We are using the org.apache.commons.lang3.text.WordUtils Class, that provides operations on Strings that contain words. The Class tries to handle null input gracefully. An exception will not be thrown for a null input. Trying to capitalize the words of a String implies that you should: Use capitalize(String str) API ...

Read More »

Generate random alphanumeric string

In this example we shall show you how to generate random alphanumeric String objects. We are using the org.apache.commons.lang3.RandomStringUtils class, that offers operations for random Strings. To generate random alphanumeric String objects one should perform the following steps: Use random(int count, boolean letters, boolean numbers) method to create a random string whose length is the number of characters specified. Use randomAlphabetic(int count) ...

Read More »

Date and Time format

With this example we are going to demonstrate how to make Date and Time formatting. We are using the org.apache.commons.lang3.time.DateFormatUtils class, that provides Date and time formatting utilities and constants. It uses the org.apache.commons.lang3.time.FastDateFormat class, that is a fast and thread-safe version of SimpleDateFormat. In short, to format Date and Time you should: Create a new Date object. Use ISO_DATETIME_FORMAT field ...

Read More »

Word counter

This is an example of how to count the words of a String paragraph, using the org.apache.commons.lang3.StringUtils class. This class provides operations on String that are null safe. Counting the words of a paragraph implies that you should: Create a String that is a paragraph. Create a String word that is the word to search in the paragraph. Use the countMatches ...

Read More »

Convert array to Map

In this example we shall show you how to convert an array to a Map. We are using the org.apache.commons.lang3.ArrayUtils class, that provides operations on arrays, primitive arrays (like int[]) and primitive wrapper arrays (like Integer[]). This class tries to handle null input gracefully. An exception will not be thrown for a null array input. To convert an array to a ...

Read More »