Displaying posts categorized under

Java

File Handling in Java

1. Finding File Information package org.vit.java.filehandling; import java.io.File;import java.io.IOException;public class FileTest{ public static void main(String[] args) { File f =new File(“/home/anthoniraj/Documents/install.txt”); /* * Tests whether the file or directory denoted by this abstract pathname exists. * Returns true if and only if the file or directory denoted by this abstract * pathname exists; false otherwise [...]

Setting Java PATH (JAVA_HOME and PATH) in LINUX

For Working with Java and its related program, we need to set Java path and homein user profile configuration file (after installaing jdk). 1. Goto Terminal and open any one of the following file # vim /etc/profile (or) # vim /root/.bash_profile (Instead of root you can also change your normal username) 2. Now Add the [...]

Grabbing Pixels From Grayscale and RGB Images Using Java

import java.awt.Image;import java.awt.Toolkit;import java.awt.image.PixelGrabber;import java.util.Date;import java.util.GregorianCalendar; /* * Author : Antony * Date : 21-Feb-08 * Program : ImageReadNew.java * Java version : 1.6.0_03 */public class NewImageRead{ //Create Red, Green,Blue 2D array int r[][], g[][], b[][]; //Create one 2D array for Grayscale int grayMatrix[][]; //Pixel Grapping Function Starts public void getImage(String input) { //Read the [...]

Grabbing Pixels From RGB Images Using Java

import java.awt.Image;import java.awt.image.PixelGrabber;import java.io.File;import java.io.IOException; import javax.imageio.ImageIO; /* * Author : Antony * Date : 14-Feb-08 * Program : ImageRead.java * Java version : 1.6.0_03 */public class ImageRead{ Image img =null; int width; int height; int pixels[] ,r[][],g[][],b[][]; int row=0,col=0; int x =0, y=0; public void readImage() { File file = new File(“/home/anthoniraj/Pictures/simple.jpeg”); try { [...]