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: java.io
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: java.io
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: API
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: API
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:
- WS – Security 1.1
- WS – Secure Conversation
- WS – Security Policy – 1.2
- WS – Trust
Apache Rampart can be downloaded from http://ws.apache.org/rampart/download.html.
Tags: API
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: java.io
Moving a file or directory in Java
The renameTo method of file class can be used for moving a file or directory to another destination.
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");
// Create the destination file/directory.
File destintation = new File("d:\\temp\\dir\\test.txt");
// Move the file
boolean status = file.renameTo(destintation);
System.out.println("Moving status - "+status);
}
}
Tags: java.io
Renaming a file in Java
The renameTo method of file class can be used for renaming a file or directory.
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");
// Create the destination file/directory.
File destintation = new File("d:\\temp\\test1.text");
// Rename the file.
boolean status = file.renameTo(destintation);
System.out.println("Renaming status - "+status);
}
}
Tags: java.io
Creating a directory with sub directory
The mkdirs method of file class is used for creating a direcory and sub directories in Java
import java.io.File;
/**
* File class examples
*/
public class FileExample {
public static void main(String[] args){
// Create file object representing the directory
File file = new File("d:\\temp\\dir\\subdir");
// Create directory and sub directories.
boolean status = file.mkdirs();
System.out.println("Directory creation status - "+status);
}
}
Tags: java.io
Create a directory using java
The mkdir method of file class is used for creating a new directory in java.
import java.io.File;
/**
* File class examples
*/
public class FileExample {
public static void main(String[] args){
// Create file object representing the directory
File file = new File("d:\\temp\\dir");
// Create directory
boolean status = file.mkdir();
System.out.println("Directory creation status - "+status);
}
}
Tags: java.io