I need to convert any arbitrary string:

  • string with spaces
  • 100stringsstartswithnumber
  • string€with%special†characters/\!
  • [empty string]

to a valid Java identifier:

  • string_with_spaces
  • _100stringsstartswithnumber
  • string_with_special_characters___
  • _

Is there an existing tool for this task?

With so many Java source refactoring/generating frameworks one would think this should be quite common task.

Edit
Report