Here you can find the source of readFromFile(URL fileName)
public static String readFromFile(URL fileName)
//package com.java2s; /******************************************************************************* * Copyright (c) 2005-2011 eBay Inc./*from ww w.ja va 2s. com*/ * 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 * *******************************************************************************/ import java.io.InputStreamReader; import java.net.URL; public class Main { public static String readFromFile(URL fileName) { try { final StringBuffer sb = new StringBuffer(); final char buf[] = new char[4096]; int numRead; final InputStreamReader isr = new InputStreamReader(fileName.openStream(), "utf-8"); do { numRead = isr.read(buf, 0, buf.length); if (numRead > 0) sb.append(buf, 0, numRead); } while (numRead >= 0); isr.close(); return sb.toString(); } catch (Exception e) { e.printStackTrace(); return null; } } }