Posts

Showing posts from May, 2012

Common LINUX Commands

Image
Who am I? Changing the password Listing the directory contents Get into a directory Learning the directory and folder user rights Reaching the command manual

Changing the user
Where am I? (Print Working Directory)
Long list


Creating a file Editing a file

Cd(Change Directory) Copying a file

Copying files to a Directory Create Directory

Removing file and directory


Thread Sample V

package pagefinder;

import java.net.URL;
import java.net.URLConnection;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Nurhak
 */
public class Worker extends Thread {

    private String threadName;
    private int startNumber;
    private int finishNumber;

    public Worker(String threadName, int startNumber, int finishNumber) {
        System.out.println(threadName+ " has started!");
        this.threadName = threadName;
        this.startNumber = startNumber;
        this.finishNumber = finishNumber;
    }

    @Override
    public void run() {
        for (int i = startNumber; i <finishNumber+1; i++) {
            try {
                URL pageUrl = new URL("http://www.samplesite/" + i + ".html");
                URLConnection pageConn = pageUrl.openConnection();
                pageConn.connect();
                String pageHeader = pageConn.getHeaderField(0);

                if ((pageHeader.indexOf("404&quo…

Thread Sample - IV

package thread4;

/**
 *
 * @author Nurhak
 */
public class Runner extends Thread {

    public Runner(String threadName) {
        super(threadName);
    }

    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            System.out.println(i + " " + getName());

            try {
                sleep((int) (Math.random() * 1000));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        System.out.println("Destination--->" + getName());
    }
}


package thread4;

/**
 *
 * @author Nurhak
 */
public class Thread4 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        new Runner("izmir").start();
        new Runner("istanbul").start();
    }
}