Here you can find the source of convert2Percent(long readsize, long totalsize)
public static String convert2Percent(long readsize, long totalsize)
//package com.java2s; //License from project: Open Source License import java.text.DecimalFormat; public class Main { public static String convert2Percent(long readsize, long totalsize) { String str = "00.00%"; float result = ((float) readsize) / (float) totalsize; System.out.println(result); DecimalFormat df = new DecimalFormat("##.##%"); str = df.format(result);/*from ww w .j a v a 2 s. c o m*/ return str; } }