Here you can find the source of toBytes(String s)
public static long toBytes(String s)
//package com.java2s; //License from project: Apache License public class Main { public static long toBytes(String s) { long size = 0; if (s.endsWith("K") || s.endsWith("k")) { size = Long.valueOf(s.substring(0, s.length() - 1).trim()) * 1024; } else if (s.endsWith("M") || s.endsWith("m")) { size = Long.valueOf(s.substring(0, s.length() - 1).trim()) * 1024 * 1024; } else if (s.endsWith("G") || s.endsWith("g")) { size = Long.valueOf(s.substring(0, s.length() - 1).trim()) * 1024 * 1024; }//w ww. j a v a2s .co m return size; } }