@SuppressWarnings("static-method") @Test public void testCreateUri() throws Exception { System.out.println(AOUtil.createURI("c:\\kaka\\naca\\/das des\\a.txt")); }
public static URI createURI(final String file) throws URISyntaxException { if (file == null || file.isEmpty()) { throw new IllegalArgumentException("No se puede crear una URI a partir de un nulo"); } String filename = file.trim(); if (filename.isEmpty()) { throw new IllegalArgumentException("La URI no puede ser una cadena vacia"); } filename = filename.replace('\\', '/'); filename = filename.replace(" ", "%20") .replace("<", "%3C") .replace(">", "%3E") .replace("\"", "%22") .replace("{", "%7B") .replace("}", "%7D") .replace("|", "%7C") .replace("^", "%5E") .replace("[", "%5B") .replace("]", "%5D") .replace("`", "%60"); final URI uri = new URI(filename); final String scheme = uri.getScheme(); for (final String element : SUPPORTED_URI_SCHEMES) { if (element.equals(scheme)) { return uri; } } if (scheme == null) { filename = filename.replace("#", "%23"); return createURI("file: } if (scheme.length() == 1 && Character.isLetter((char) scheme.getBytes()[0])) { filename = filename.replace("#", "%23"); return createURI("file: } throw new URISyntaxException(filename, "Tipo de URI no soportado"); }
AOUtil { public static URI createURI(final String file) throws URISyntaxException { if (file == null || file.isEmpty()) { throw new IllegalArgumentException("No se puede crear una URI a partir de un nulo"); } String filename = file.trim(); if (filename.isEmpty()) { throw new IllegalArgumentException("La URI no puede ser una cadena vacia"); } filename = filename.replace('\\', '/'); filename = filename.replace(" ", "%20") .replace("<", "%3C") .replace(">", "%3E") .replace("\"", "%22") .replace("{", "%7B") .replace("}", "%7D") .replace("|", "%7C") .replace("^", "%5E") .replace("[", "%5B") .replace("]", "%5D") .replace("`", "%60"); final URI uri = new URI(filename); final String scheme = uri.getScheme(); for (final String element : SUPPORTED_URI_SCHEMES) { if (element.equals(scheme)) { return uri; } } if (scheme == null) { filename = filename.replace("#", "%23"); return createURI("file: } if (scheme.length() == 1 && Character.isLetter((char) scheme.getBytes()[0])) { filename = filename.replace("#", "%23"); return createURI("file: } throw new URISyntaxException(filename, "Tipo de URI no soportado"); } }
AOUtil { public static URI createURI(final String file) throws URISyntaxException { if (file == null || file.isEmpty()) { throw new IllegalArgumentException("No se puede crear una URI a partir de un nulo"); } String filename = file.trim(); if (filename.isEmpty()) { throw new IllegalArgumentException("La URI no puede ser una cadena vacia"); } filename = filename.replace('\\', '/'); filename = filename.replace(" ", "%20") .replace("<", "%3C") .replace(">", "%3E") .replace("\"", "%22") .replace("{", "%7B") .replace("}", "%7D") .replace("|", "%7C") .replace("^", "%5E") .replace("[", "%5B") .replace("]", "%5D") .replace("`", "%60"); final URI uri = new URI(filename); final String scheme = uri.getScheme(); for (final String element : SUPPORTED_URI_SCHEMES) { if (element.equals(scheme)) { return uri; } } if (scheme == null) { filename = filename.replace("#", "%23"); return createURI("file: } if (scheme.length() == 1 && Character.isLetter((char) scheme.getBytes()[0])) { filename = filename.replace("#", "%23"); return createURI("file: } throw new URISyntaxException(filename, "Tipo de URI no soportado"); } private  AOUtil(); }
AOUtil { public static URI createURI(final String file) throws URISyntaxException { if (file == null || file.isEmpty()) { throw new IllegalArgumentException("No se puede crear una URI a partir de un nulo"); } String filename = file.trim(); if (filename.isEmpty()) { throw new IllegalArgumentException("La URI no puede ser una cadena vacia"); } filename = filename.replace('\\', '/'); filename = filename.replace(" ", "%20") .replace("<", "%3C") .replace(">", "%3E") .replace("\"", "%22") .replace("{", "%7B") .replace("}", "%7D") .replace("|", "%7C") .replace("^", "%5E") .replace("[", "%5B") .replace("]", "%5D") .replace("`", "%60"); final URI uri = new URI(filename); final String scheme = uri.getScheme(); for (final String element : SUPPORTED_URI_SCHEMES) { if (element.equals(scheme)) { return uri; } } if (scheme == null) { filename = filename.replace("#", "%23"); return createURI("file: } if (scheme.length() == 1 && Character.isLetter((char) scheme.getBytes()[0])) { filename = filename.replace("#", "%23"); return createURI("file: } throw new URISyntaxException(filename, "Tipo de URI no soportado"); } private  AOUtil(); static URI createURI(final String file); static InputStream loadFile(final URI uri); static byte[] getDataFromInputStream(final InputStream input); static String getCN(final X509Certificate c); static String getCN(final String principal); static String getRDNvalueFromLdapName(final String rdn, final String principal); static boolean isPseudonymCert(final X509Certificate cert); static String hexify(final byte abyte0[], final boolean separator); static String hexify(final byte abyte0[], final String separator); static void loadNativeLibrary(final String path); static void copyFile(final File source, final File dest); static String[] split(final String text, final String sp); static String properties2Base64(final Properties p); static Properties base642Properties(final String base64); static String propertiesAsString(final Properties p); static boolean isJava9orNewer(); static boolean isOnlyNumber(final String value); }
AOUtil { public static URI createURI(final String file) throws URISyntaxException { if (file == null || file.isEmpty()) { throw new IllegalArgumentException("No se puede crear una URI a partir de un nulo"); } String filename = file.trim(); if (filename.isEmpty()) { throw new IllegalArgumentException("La URI no puede ser una cadena vacia"); } filename = filename.replace('\\', '/'); filename = filename.replace(" ", "%20") .replace("<", "%3C") .replace(">", "%3E") .replace("\"", "%22") .replace("{", "%7B") .replace("}", "%7D") .replace("|", "%7C") .replace("^", "%5E") .replace("[", "%5B") .replace("]", "%5D") .replace("`", "%60"); final URI uri = new URI(filename); final String scheme = uri.getScheme(); for (final String element : SUPPORTED_URI_SCHEMES) { if (element.equals(scheme)) { return uri; } } if (scheme == null) { filename = filename.replace("#", "%23"); return createURI("file: } if (scheme.length() == 1 && Character.isLetter((char) scheme.getBytes()[0])) { filename = filename.replace("#", "%23"); return createURI("file: } throw new URISyntaxException(filename, "Tipo de URI no soportado"); } private  AOUtil(); static URI createURI(final String file); static InputStream loadFile(final URI uri); static byte[] getDataFromInputStream(final InputStream input); static String getCN(final X509Certificate c); static String getCN(final String principal); static String getRDNvalueFromLdapName(final String rdn, final String principal); static boolean isPseudonymCert(final X509Certificate cert); static String hexify(final byte abyte0[], final boolean separator); static String hexify(final byte abyte0[], final String separator); static void loadNativeLibrary(final String path); static void copyFile(final File source, final File dest); static String[] split(final String text, final String sp); static String properties2Base64(final Properties p); static Properties base642Properties(final String base64); static String propertiesAsString(final Properties p); static boolean isJava9orNewer(); static boolean isOnlyNumber(final String value);  }