Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;

import java.io.IOException;

public class Main {
    public static String[] getAvailableSchedulers() {
        File iofile = new File("/sys/block/mmcblk0/queue/scheduler");
        String s = "";
        FileInputStream fin2 = null;
        try {
            fin2 = new FileInputStream(iofile);
            byte fileContent[] = new byte[(int) iofile.length()];
            fin2.read(fileContent);
            s = new String(fileContent).trim().split("\n")[0];
        } catch (FileNotFoundException e) {
            //System.out.println("File not found" + e);
        } catch (IOException ioe) {
            //System.out.println("Exception while reading file " + ioe);
        } finally {
            try {
                if (fin2 != null) {
                    fin2.close();
                }
            } catch (IOException ioe) {
                //System.out.println("Error while closing stream: " + ioe);
            }
        }
        String[] IOSchedulers = s.replace("[", "").replace("]", "").split(" ");
        return IOSchedulers;
    }
}