
RSS6 Video Tour
|
 |
|
Get file separator symbol on windows and linux
|
|
Example file separator Java
Every operating system has its own way of separating the paths. Some may use / while others may use as the separator character. For e.g UNIX has a path like /usr/home but Windows will have paths like c:test.txt
When File I/O operations are performed a Java
|
|
| (Published: Fri, 06 Jan 2012 16:40:01 +0000) |
|
|
|
What is Autoboxing?
|
|
Autoboxing example
Autoboxing was introduced in JDK 5.0 and is used to automatically convert primitive data types to wrapper class objects. The primitives include int, float, long and byte etc and their corresponding wrapper classes include Int, Float, Long and Byte classes.
The following
|
|
| (Published: Fri, 06 Jan 2012 15:28:16 +0000) |
|
|
|
Best way to check for an empty string
|
|
Check Empty String in Java
There are multiple ways to find if a string is empty in Java. Even some String utility also provide helper methods to check is the string is empty. By empty string we mean the contents of the string is blank (which is same as “”).
The following program shows how the
|
|
| (Published: Fri, 06 Jan 2012 14:53:43 +0000) |
|
|
|
How to exit java program
|
|
There are multiple ways in which a program can exit and stop its execution. When a Java application is running then JVM remains active till any single user thread is running. When all user threads have stopped working and only daemon threads are running then JVM exits.
The following are the
|
|
| (Published: Thu, 05 Jan 2012 16:39:07 +0000) |
|
|
|
File last modification date
|
|
File modification date in Java
Whenever a file is modified, the date is stored by the operating system. The following program can be used to print the date and time when the file was last modified either manually or by using the Java program.
package com.example; import java.io.File;import
|
|
| (Published: Thu, 05 Jan 2012 16:09:51 +0000) |
|
|
|
Java Application without a main method
|
|
Program without main method
The main method is the starting point of any Java program. The JVM invokes the main method and then the main method calls various other methods or starts various threads. But one can also invoke print statements or create threads without the main method.
The
|
|
| (Published: Thu, 05 Jan 2012 15:45:46 +0000) |
|
|
|
Create zip files in Java
|
|
Create Zip File in Java
Normally one needs to use some kind of tool to create zip files which can contain a number of files in
compressed format. This helps in saving space and also combining various files as a single file. Sometimes
Java applications also need to create zip files and Java
|
|
| (Published: Thu, 05 Jan 2012 15:23:20 +0000) |
|
|
|
Copying One File to Another
|
|
How to copy a file in Java
File copy operation can be performed in multiple ways in Java. The methods include using the console command or using the Java File copy I/O API. Again the file copy operation can be performed by using Stream as well as Writer classes. The following code example shows
|
|
| (Published: Thu, 05 Jan 2012 06:10:13 +0000) |
|
|
|
Using Timezone with Date in Java
|
|
TimeZone Date Example
A Date object in Java is used to represent the date in terms of milliseconds starting from 1st Jan 1970. When
a Date object is created, its timezone can be set ti a different one by using the corresponding setter method of
Date class.
The following program shows how to
|
|
| (Published: Wed, 04 Jan 2012 14:46:08 +0000) |
|
|
|
Current Thread in Java Program
|
|
Get current thread java
When a piece of code is being executed by a number of threads and it is required to get a reference to
current thread and then take some action based on the condition like thread name or priority then
currenthread() method is used. currentthread() method of Thread
|
|
| (Published: Wed, 04 Jan 2012 14:43:24 +0000) |
|
|
|
Stack Trace in Java
|
|
Java Exception and Stack Trace
Whenever an exception is raised in a Java application then some kind of debug information is supplied by
JVM in terms of the source of exception and the heirarchy of method calls which resulted in the exception to
be raised. This debug information provided by
|
|
| (Published: Wed, 04 Jan 2012 14:39:16 +0000) |
|
|
|
How to rename file in Java
|
|
Rename Files in Java
A file can be renamed by using rename command in DOS prompt. Similarly there are commands for
renaming file in UNIX and LINUX. But a file can also be renamed by using a java program. The File class
can be used to rename a file as shown in the program below:
package
|
|
| (Published: Wed, 04 Jan 2012 14:32:04 +0000) |
|
|
|
Program to generate Random integer less than 100 in Java
|
|
Java random number between 1 and 100
The random() method of Math class returns a random float less than 0.1. If a java program needs to generate
integer values less than 100, then one can use the following code.
package com.example; /** This class is a Java tutorial for generating random
|
|
| (Published: Wed, 04 Jan 2012 14:29:15 +0000) |
|
|
|
List of TimeZones in Java
|
|
TimeZone list in Java
A Java program to make use of timezones needs to use TimeZone class in order to display date and time as
per the current country in which the application is running. This is more important in web applications which
are widely used. Java has a good support of Timezones
|
|
| (Published: Wed, 04 Jan 2012 14:26:09 +0000) |
|
|
| ( Source: http://extreme-java.com/feed/ ) |
Get social!!!
|
|
 |
|
Search Our Feeds Database!
|
|