1. hafta örnek
1. örnek disk boş alan
public static void disk(){
File file = new File("c:");
long totalSpace = file.getTotalSpace(); //toplam boş alan
long usableSpace = file.getUsableSpace();
long freeSpace = file.getFreeSpace();
System.out.println(" === Partition Detail ===");
System.out.println(" === bytes ===");
System.out.println("Toplam alan : " + totalSpace + " bytes");
System.out.println("toplam bos kullanilabilir : " + usableSpace + " bytes");
System.out.println("bos alan : " + freeSpace + " bytes");
System.out.println(" === mega bytes ===");
System.out.println("mb cinsinden toplam : " + totalSpace /1024 /1024 + " mb");
System.out.println("mb cinsinden toplam kullanilabilir : " + usableSpace /1024 /1024 + " mb");
System.out.println("mb cinsinden toplam bos : " + freeSpace /1024 /1024 + " mb");
}
2.örnek: internet bağlantısı kontrolü
public static void eris(){
boolean connectivity;
try {
URL url = new URL("http://www.cs.sakarya.edu.tr/");
URLConnection c>
conn.connect();
c>true;
} catch (Exception e) {
c>false;
}
if(c>true)
System.out.println("baglanti var");
}
3. örnek Çalışan processlerin görüntülenmesi
try {
String line;
Process p = Runtime.getRuntime().exec("ps -e");
BufferedReader input =
new BufferedReader(new InputStreamReader(p.getInputStream()));
while ((line = input.readLine()) != null) {
System.out.println(line); //<-- Parse data here.
}
input.close();
} catch (Exception err) {
err.printStackTrace();
}
İletişim
muhammedozturk@sakarya.edu.tr+90 (264) 295 69 09