public static Token nextToken(TokenStream input, Token reusableToken) throws IOException {
		if(input == null) {
			return null;
		}
		if(!input.incrementToken()) {
			return null;
		}

		CharTermAttribute termAtt = input.getAttribute(CharTermAttribute.class);
		OffsetAttribute offsetAtt = input.getAttribute(OffsetAttribute.class);
		TypeAttribute typeAtt = input.getAttribute(TypeAttribute.class);

		if(reusableToken == null) {
			reusableToken = new Token();
		}

		reusableToken.clear();
		if(termAtt != null) {
			//lucene 3.0
			//reusableToken.setTermBuffer(termAtt.termBuffer(), 0, termAtt.termLength());
			//lucene 3.1
			reusableToken.copyBuffer(termAtt.buffer(), 0, termAtt.length());
		}
		if(offsetAtt != null) {
			//lucene 3.1
			//reusableToken.setStartOffset(offsetAtt.startOffset());
			//reusableToken.setEndOffset(offsetAtt.endOffset());
			//lucene 4.0
			reusableToken.setOffset(offsetAtt.startOffset(), offsetAtt.endOffset());
		}

		if(typeAtt != null) {
			reusableToken.setType(typeAtt.type());
		}

		return reusableToken;
	}