JAva Webソースの読み取り文字化けし

998 ワード

public void getHTMLSrc(String url){
		InputStream openStream = null;
		BufferedReader buf = null;
		
		try {
			String line = null;
			URL theUrl= new URL(url);
			openStream = theUrl.openStream();
//<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
//             HTML    	charset  	
buf = new BufferedReader(new InputStreamReader(openStream,"utf-8"));
			
			while((line = buf.readLine()) != null){
				System.out.println(line);
			
			}
		} catch (MalformedURLException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} finally{
			try {
				if(openStream!=null){
					openStream.close();
				}
				if(buf!=null){
					buf.close();
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
		}

	}