I tried to URLDecode.decode the string before I add it to the majorComponents but it doesn't work.
Therefore, my question is if there is a way to have a key that contains slash characters. Please have in mind that I would prefer not to split the string into multiple components every time a slash character occurs in the string.
All Unicode characters are allowed in a key component, including slashes. Your code to create the key is correct, and the key component does contain a slash. The slash is escaped by the Key.toString method for two reasons: 1) to delineate key components, 2) to provide a URI syntax. If you call Key.getMajorPath and look at the component, you'll see the un-escaped slash. The Key.toString javadoc contains complete documentation of the string format.