Code example for StringTokenizer

Methods: countTokens, nextToken

0
		return lastShown.getTime() + "|" + numberOfShow + "|" + hitCount;
	} 
 
	public static CampaignStatus fromString( final String string )
	{ 
		final StringTokenizer tokenizer = new StringTokenizer(string, "|");
 
		final CampaignStatus status = new CampaignStatus();
 
		if ( tokenizer.countTokens() == 3 )
		{ 
			final long time = Long.parseLong(tokenizer.nextToken());
			status.setLastShown(new Date(time));
			final int shows = Integer.parseInt(tokenizer.nextToken());
			status.setNumberOfShow(shows);
			final int hits = Integer.parseInt(tokenizer.nextToken());
			status.setHitCount(hits);
		} 
		return status;
	} 
}