Code example for InputSource

Methods: setEncoding

0
	 */ 
	public void parse(final InputStream inputStream, final Handler handler,
			final String charset) throws ParseException {
		log.debug("Parsing {}", handler.getClass().getSimpleName());
		handler.setParser(this);
		final InputSource inputSource = new InputSource(inputStream);
		inputSource.setEncoding(charset);
		try { 
			if (handler instanceof HandlerXml) { 
				xmlParser
						.parse(inputStream,
								(handler instanceof ExpressionFilter) ? new ExpressionHandler( 
										handler) : handler); 
			} else if (handler instanceof HandlerHtml) { 
				htmlParser
						.parse(inputSource,
								(handler instanceof ExpressionFilter) ? new ExpressionHandler( 
										handler) : handler); 
			} else 
				throw new ParseException(String.format(
						"Unsupported Handler [%s]", handler.getClass()));