Write code to Reads a file and converts it to String
//package com.book2s; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { /************************************************************************** * Reads a file and converts it to String **************************************************************************/ static public String url2String(java.net.URL location) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader( location.openStream(), "UTF-8")); StringBuffer strbuf = new StringBuffer(); String line = in.readLine(); while (line != null) { strbuf.append(line).append('\n'); line = in.readLine();/*from w ww .j a v a 2 s . c om*/ } return strbuf.toString(); } }