Code example for Format

Methods: format, sleep

0
			sizeUnits = "B";
		} 
		 
		overheadUp.setText("Overhead: " + size + " " + sizeUnits);
		 
		cpuUsage.setText("CPU: " + usageFormat.format(readUsage()));
		 
		consoleText.setText(btStats.getConsoleText());
		updateHandler.removeCallbacks(updater);
		updateHandler.postDelayed(updater, 5000);
	} 
 
	@Override 
	public void onClick(View v) {
		if (v == scrollStart){
			scroller.fullScroll(ScrollView.FOCUS_UP);
		} 
		else if (v == scrollEnd){
			scroller.fullScroll(ScrollView.FOCUS_DOWN);
		} 
	} 
	 
	private long lastIdle = 0;
	private long lastCPU = 0;
	 
	private float readUsage() { 
	    try { 
	        RandomAccessFile reader = new RandomAccessFile("/proc/stat", "r");
	        String load = reader.readLine();
 
	        String[] toks = load.split(" ");
 
	        long idle1 = Long.parseLong(toks[5]);
	        long cpu1 = Long.parseLong(toks[2]) + Long.parseLong(toks[3]) + Long.parseLong(toks[4])
	              + Long.parseLong(toks[6]) + Long.parseLong(toks[7]) + Long.parseLong(toks[8]);
	        long idle2, cpu2;
		    if (lastCPU + lastIdle == 0){
		        try { 
		            Thread.sleep(360);
		        } catch (Exception e) {}
	 
		        reader.seek(0);
		        load = reader.readLine();
		        reader.close();