Search

Loading

Wednesday, June 13, 2012

How to get List of Java Threads

The following code returns a list of Java Threads :
package ListThreads;

import java.util.Set;

public class ListOfThreads {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Set threadSet = Thread.getAllStackTraces().keySet();
Thread[] threadArray = threadSet.toArray(new Thread[threadSet.size()]);
for(int i=0;i
System.out.println(threadArray[i].getName().toString());
}
}
}
Original Article : http://developerpages.gr/index.php/el/desktop-development-2/java/47-how-to-get-list-of-java-threads

Write data to text file with Java

Create text file and write data with java :
/*
* www.developerpages.gr
* Create text file and write data
*/
package writetofile;

import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.logging.Level;
import java.util.logging.Logger;


public class WriteToFile {

Read data from text file with java

Read data from text file with java and write to screen :
/**
www.Developerpages.gr
* Read data from text file
*/
package readfromfile;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;


public class ReadFromFile {

Java "Hello World " Program

Γράφοντας "Hello World !" με Java :


public class helloworld {

        public static void main(String args[])
        {
           System.out.println("Hello World!");
        }
}
Original article : http://developerpages.gr/index.php/el/desktop-development-2/java/6-java-hello-world-program