Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import android.text.TextUtils;

public class Main {

    public static int getCPUOnlineCores(String online_info) {
        if (TextUtils.isEmpty(online_info)) {
            return -1;
        }

        int result = 0;

        String[] nums;
        for (String temp_str : online_info.split(",")) {
            nums = temp_str.split("-");
            switch (nums.length) {
            case 1:
                ++result;
                break;
            case 2:
                result += (Integer.parseInt(nums[1]) - Integer.parseInt(nums[0])) + 1;
            }
        }

        return result;
    }
}