JcrStringHelper { public static String pathEncode( String path ) { String[] folders = path.split( SEPARATOR ); StringBuilder encodedPath = new StringBuilder( path.length() * 2 ); for ( int i = 0; i < folders.length; i++ ) { encodedPath.append( fileNameEncode( folders[i] ) ); if ( i != folders.length - 1 || path.endsWith( SEPARATOR ) ) { encodedPath.append( SEPARATOR ); } } return encodedPath.toString(); } private  JcrStringHelper(); static String fileNameEncode( String fileName ); static String fileNameEncode( String fileName, boolean useMultiByte ); static String idEncode( String id ); static String fileNameDecode( String encodedFileName ); static String fileNameDecode( String encodedFileName, boolean useMultiByte ); static String pathEncode( String path ); static String pathEncode( String path, boolean useMultiByte ); static String pathDecode( String encodedPath ); static String pathDecode( String encodedPath, boolean useMultiByte ); static boolean isMultiByteEncodingEnabled(); static void setMultiByteEncodingEnabled( boolean useMultiByteEncoding ); static boolean isEncoded( String path );  }
@Test public void testFilePathEncode() { String path = "/asdf/err"; String encodedPath = JcrStringHelper.pathEncode( path ); assertEquals( path, encodedPath ); }