Here you can find the source of sizeOfWriteLength(int len)
static int sizeOfWriteLength(int len)
//package com.java2s; //* Licensed Materials - Property of IBM, Miracle A/S, and * public class Main { static int sizeOfWriteLength(int len) { if (len < 0) { throw new RuntimeException("Invalid length < 0"); }/*from w w w . ja v a 2s . c o m*/ if (len <= 127) { return 1; } else if (len <= 16383) { return 2; } else if (len <= 2097151) { return 3; } else { throw new RuntimeException("Invalid length > 2^21-1"); } } }