Here you can find the source of toBufferedInputStream(InputStream stream)
private static InputStream toBufferedInputStream(InputStream stream)
//package com.java2s; /******************************************************************************* * Copyright (c) 2005, 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * //from w w w . j a v a2s . co m *******************************************************************************/ import java.io.BufferedInputStream; import java.io.InputStream; public class Main { private static final int DEFAULT_READING_SIZE = 8192; private static InputStream toBufferedInputStream(InputStream stream) { if (stream instanceof BufferedInputStream) { return stream; } else { return new BufferedInputStream(stream, DEFAULT_READING_SIZE); } } }