Java Tutorials
261. Simple Port Scanner application using Java
By: Syed M Hussain : 2007-09-03
Description: In this article I will explain how to develop a simple port scanner which you can use to scan a host for open ports. A port scanner is a software tool used by network administrators to scan a host network for open ports. This allows the administrator to check their network security.
262. Executing other system commands and programs from a Java Program
By: Emiley J : 2007-09-02
Description: In safe environments, you can use Java to execute other heavyweight processes (that is, programs) on your multitasking operating system. Several forms of the exec() method allow you to name the program you want to run as well as its input parameters. The exec() method returns a Process object, which can then be used to control how your Java program interacts with this new running process. Because Java can run on a variety of platforms and under a variety of operating systems, exec() is inherently environment-dependent.
263. ThreadGroup Sample in Java
By: Mashoud : 2007-09-02
Description: Thread groups offer a convenient way to manage groups of threads as a unit. This is particularly valuable in situations in which you want to suspend and resume a number of related threads. For example, imagine a program in which one set of threads is used for printing a document, another set is used to display the document on the screen, and another set saves the document to a disk file. If printing is aborted, you will want an easy way to stop all threads related to printing. Thread groups offer this convenience. The following program, which creates two thread groups of two threads each, illustrates this usage:
264. How to use ArrayList in Java
By: Hong : 2007-09-02
Description: The ArrayList class extends AbstractList and implements the List interface. ArrayList supports dynamic arrays that can grow as needed. In Java, standard arrays are of a fixed length. After arrays are created, they cannot grow or shrink, which means that you must know in advance how many elements an array will hold. But, sometimes, you may not know until run time precisely how large of an array you need. To handle this situation, the collections framework defines ArrayList. In essence, an ArrayList is a variable-length array of object references. That is, an ArrayList can dynamically increase or decrease in size. Array lists are created with an initial size. When this size is exceeded, the collection is automatically enlarged. When objects are removed, the array may be shrunk.
265. How to use Iterator in Java
By: Fazal : 2007-09-02
Description: Before you can access a collection through an iterator, you must obtain one. Each of the collection classes provides an iterator() method that returns an iterator to the start of the collection. By using this iterator object, you can access each element in the collection, one element at a time. In general, to use an iterator to cycle through the contents of a collection, follow these steps:
266. Using StringTokenizer in Java
By: Emiley J : 2007-09-02
Description: The processing of text often consists of parsing a formatted input string. Parsing is the division of text into a set of discrete parts, or tokens, which in a certain sequence can convey a semantic meaning. The StringTokenizer class provides the first step in this parsing process, often called the lexer (lexical analyzer) or scanner. StringTokenizer implements the Enumeration interface. Therefore, given an input string, you can enumerate the individual tokens contained in it using StringTokenizer.
267. Using totalMemory() and freeMemory() in Java
By: Hong : 2007-09-02
Description: Although Java provides automatic garbage collection, sometimes you will want to know how large the object heap is and how much of it is left. You can use this information, for example, to check your code for efficiency or to approximate how many more objects of a certain type can be instantiated. To obtain these values, use the totalMemory() and freeMemory() methods.
268. Converting Numbers to and from Strings using Java
By: Mashoud : 2007-09-02
Description: One of the most common programming chores is converting the string representation of a number into its internal, binary format. Fortunately, Java provides an easy way to accomplish this. The Byte, Short, Integer, and Long classes provide the parseByte(), parseShort(), parseInt(), and parseLong() methods, respectively. These methods return the byte, short, int, or long equivalent of the numeric string with which they are called. (Similar methods also exist for the Float and Double classes.)
269. Understanding isInfinite() and isNaN() in Java
By: Emiley J : 2007-09-02
Description: Float and Double provide the methods isInfinite() and isNaN(), which help when manipulating two special double and float values. These methods test for two unique values defined by the IEEE floating-point specification: infinity and NaN (not a number).
270. Using toLowerCase() and toUpperCase() in Java
By: Mashoud : 2007-09-02
Description: The method toLowerCase() converts all the characters in a string from uppercase to lowercase. The toUpperCase() method converts all the characters in a string from lowercase to uppercase. Nonalphabetical characters, such as digits, are unaffected. Here are the general forms of these methods: