DocumentUtils { public static String getFilename(String uriStr) throws URISyntaxException { URI uri = new URI(uriStr); String path; if (uri.isOpaque()) { path = uri.getSchemeSpecificPart(); } else { path = uri.getPath(); } return FilenameUtils.getName(path); } private  DocumentUtils(); static String getMetadataTypeName(); static TypeDescription getMetadataTypeDescription(TypeSystemDescription tsd); static void setDocumentUri(CAS cas, String uri, boolean createDocMeta); static String getDocumentUri(CAS cas); static String getDocumentUri(JCas jcas); static String getDocumentFilename(CAS cas); static String getFilename(String uriStr); static String getFilenameSafe(String uriStr); static final String TYPESYSTEM_COMMONS; }
@Test public void testGetFilename() throws URISyntaxException { assertEquals("1.txt", DocumentUtils.getFilename("file:corpus/1.txt")); assertEquals("1.txt", DocumentUtils.getFilename("corpus/1.txt")); assertEquals("1.txt", DocumentUtils.getFilename("file:/corpus/1.txt")); }