JDK-8180207 : deprecate StringTokenizer and StreamTokenizer
  • Type: Sub-task
  • Component: core-libs
  • Sub-Component: java.util
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2017-05-11
  • Updated: 2025-06-20
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Description
The documentation says,

«StringTokenizer is a legacy class that is retained for compatibility reasons although its use is discouraged in new code. It is recommended that anyone seeking this functionality use the split method of String or the java.util.regex package instead.»

I'd also add that java.util.Scanner mostly supplants the token-based reading methods, with the exception of countTokens().

StreamTokenizer is kind of in the same boat as StringTokenizer. (Also note that StreamTokenizer is in java.io.)
Comments
In addition to being updated to mention Scanner, the "legacy class" paragraph of the StringTokenizer documentation is probably best moved to the top of the class doc, independent of whether we decide to deprecate the class. I note that StringTokenizer has been considered a legacy class since at least 2005: https://bugs.openjdk.org/browse/JDK-6318032?focusedId=12242524&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-12242524
20-06-2025