HOME      BLOG       FORUMS      CONTACT       ABOUT

Finds out total free space available in a partition using java

June 24th, 2008 Albin Joseph Posted in java.io | No Comments »

Finds out total free space available in a partition using java

The getFreeSpace method of File class can be used for getting the total free space available in a partition or drive using java.

import java.io.File;
/**
 * File class examples.
 *
 */
public class FileExample  {
	public static void main(String[] args){
		// Create file object representing the source file/directory
		File file = new File("d:\\temp\\test.txt");

		// Get the total free space available in current drive
		long value = file.getFreeSpace();

		// Convert it to GigaBytes
		double valueGB = (double) value / 1024 / 1024 / 1024;

		System.out.println("Total free space available in the current partition is "+valueGB);
	}
}

Tags: , , , ,

AddThis Social Bookmark Button

Finds out total space available in a partition using java

June 24th, 2008 Albin Joseph Posted in java.io | No Comments »

Finds out total space available in a partition using java

The getTotalSpace method of File class can be used for getting the total space available in a partition or drive using java.

import java.io.File;
/**
 * File class examples.
 *
 */
public class FileExample  {
	public static void main(String[] args){
		// Create file object representing the source file/directory
		File file = new File("d:\\temp\\test.txt");

		// Get the total space available in current drive
		long value = file.getTotalSpace();

		// Convert it to GigaBytes
		double valueGB = (double) value / 1024 / 1024 / 1024;

		System.out.println("Total space available in the current partition is "+valueGB);
	}
}

Tags: , , , ,

AddThis Social Bookmark Button

Lists all the drives present in Windows using java

June 24th, 2008 Albin Joseph Posted in java.io | No Comments »

Lists all the drives present in Windows using java

The listRoots method of File class is used for finding out all the drives available in Windows.

import java.io.File;
/**
 * File class examples.
 *
 */
public class FileExample  {
	public static void main(String[] args){
		// Get all the drives
		File drives[] = File.listRoots();

		// Loop through the drive list and display the drives.
		for (int index = 0; index < drives.length; index++) {
			System.out.println(drives[index]);
		}
	}
}

Note: Since Linux does not have any drives concept, the output of the above program in Linux operating system will be "/"

Tags: , , , ,

AddThis Social Bookmark Button

Checks whether a file or directory has executable permission or not.

June 24th, 2008 Albin Joseph Posted in java.io | No Comments »

Checks whether a file or directory has executable permission or not.

The canExecute method of File class can be used for finding out whether the given file has executable permission or not.

import java.io.File;
/**
 * File class examples.
 *
 */
public class FileExample  {
	public static void main(String[] args){
		// Create file object representing the source file/directory
		File file = new File("d:\\temp");

		// Check whether the file has executable permission or not.
		boolean value = file.canExecute();

		System.out.println("File executable permission status : "+value);
	}
}

Tags: , , , ,

AddThis Social Bookmark Button

Change file or directory permission only to owner using java

June 24th, 2008 Albin Joseph Posted in java.io | No Comments »

Change file or directory permission only to owner using java

The setReadOnly, setWritable,setReadable and setExecutable methods of the file class is used for changing the permissions on a file only to owner of the file or directory.

import java.io.File;
/**
 * File class examples.
 *
 * The class sets read only, writable, executable and readable permissions
 * for a file or directory. This permissions will be applied to the owner of
 * the file or directory only. Not everyone will get the permissions.
 */
public class FileExample  {
	public static void main(String[] args){
		// Create file object representing the source file/directory
		File file = new File("d:\\temp\\test.txt");

		// Given below are the different file permissions
		// operations that can be performed on java.

		// Give executable permission to a file or directory
		file.setExecutable(true, true);

		// Set read only property to a file or a directory
		file.setReadOnly();

		// Give write permission to the file
		file.setWritable(true, true);

		// Make the file or directory as readable
		file.setReadable(true, true);
	}
}

Tags: , , , ,

AddThis Social Bookmark Button

Change file or directory permission using java

June 24th, 2008 Albin Joseph Posted in java.io | No Comments »

Change file or directory permission using java

The setReadOnly, setWritable,setReadable and setExecutable methods of the file class is used for changing the permissions on a file.

import java.io.File;
/**
 * File class examples.
 * Performs different permission operations on a file or directory.
 */
public class FileExample  {
	public static void main(String[] args){
		// Create file object representing the source file/directory
		File file = new File("d:\\temp\\test.txt");

		// Given below are the different file permissions
		// operations that can be performed on java.

		// Make the file or directory as executable
		file.setExecutable(true);

		// Make the file or directory as read only
		file.setReadOnly();

		// Make the file as writable.
		file.setWritable(true);

		// Give read permission to the file or directory
		file.setReadable(true);
	}
}

Tags: , , , ,

AddThis Social Bookmark Button

Kilim – message-passing framework for Java

June 24th, 2008 Albin Joseph Posted in API | No Comments »

Kilim is a message-passing framework for Java that provides ultra-lightweight threads and facilities for fast, safe, zero-copy messaging between these threads.

It consists of a bytecode postprocessor (a “weaver”), a run time library with buffered mailboxes (multi-producer, single consumer queues) and a user-level scheduler and a type system that puts certain constraints on pointer aliasing within messages to ensure interference-freedom between threads.

http://www.malhar.net/sriram/kilim/index.html

Tags: , , , ,

AddThis Social Bookmark Button

ItsNat: Natural Ajax

June 18th, 2008 Albin Joseph Posted in API | No Comments »

ItsNat: Natural Ajax

ItsNat: Natural Ajax. Component Based Java Web Application Framework

ItsNat is an innovative open source Java AJAX Component based Web Framework, it offers a natural approach to modern web development.

Why natural? ItsNat leverages the old tools to build the new AJAX based Web 2.0 applications: pure (X)HTML and pure Java W3C DOM!

ItsNat is server centric using a unique approach called TBITS, “The Browser Is The Server”. ItsNat simulates a Universal W3C Java Browser at the server, with ItsNat the server mimics the behavior of a web browser, containing a W3C DOM Level 2 node tree and receiving W3C DOM Events.

Core features

ItsNat provides many more (core) features:

  • Client to server synchronization
  • Web-continuations (“continue” events)
  • User defined event types
  • Timers
  • Long running server tasks
  • COMET without special application servers
  • DOM utils (to simplify DOM manipulation)
  • Resolution of ${} based variables in markup
  • ElementCSSInlineStyle support in the server
  • Automatic page remote/view control of other users/sessions!!
  • XML generation
  • Non-HTML namespaces support like pure SVG with AJAX and SVG embedded in XHTML
  • JavaScript generation utilities
  • Events fired by the server sent to the client simulating user actions for instance to test the view from the server
  • Custom pretty URLs
  • Previous/forward document navigation (pull and push referrers with back/forward button support
  • Degraded modes (AJAX disabled and JavaScript disabled modes)

Tags: , , , ,

AddThis Social Bookmark Button

Apache Rampart

June 18th, 2008 Albin Joseph Posted in API | No Comments »

Apache Rampart

Apache Rampart is a security module for Axis 2. It secures SOAP messages according to specifications in the WS-Security stack. Rampart implements the following specifications:

  1. WS – Security 1.1
  2. WS – Secure Conversation
  3. WS – Security Policy – 1.2
  4. WS – Trust

Apache Rampart can be downloaded from http://ws.apache.org/rampart/download.html.

Tags: , , ,

AddThis Social Bookmark Button

Change the last modified date of a file or directory.

June 2nd, 2008 Albin Joseph Posted in java.io | No Comments »

Change the last modified date of a file or directory.

The setLastModified method of file class can be used for changing the last modified time of a directory or a file.

import java.io.File;
import java.util.Date;
/**
 * File class examples
 */
public class FileExample  {
	public static void main(String[] args){
		// Create file object representing the source file/directory
		File file = new File("d:\\temp\\test.txt");

		// Get the current time
		long time = new Date().getTime();

		// Change the last modified time.
		file.setLastModified(time);
	}
}

Tags: , , , ,

AddThis Social Bookmark Button