import java.nio.charset.StandardCharsets; 
import java.nio.file.FileSystem; 
import java.nio.file.FileSystems; 
import java.nio.file.Files; 
import java.nio.file.Path; 
import java.nio.file.Paths; 
import java.nio.file.ProviderMismatchException; 
import java.util.zip.ZipEntry; 
import java.util.zip.ZipOutputStream; 

public class JI9050361 {
	public static void main(String[] args) throws Exception { 
		Path tempFile = Files.createTempFile("ZipTest", ".zip"); 
		try { 
			try (ZipOutputStream out = 
					new ZipOutputStream(Files.newOutputStream(tempFile))) { 
				out.putNextEntry(new ZipEntry("test/hello.txt")); 
				out.write("Hello, World!".getBytes(StandardCharsets.UTF_8)); 
				out.closeEntry(); 
			} 
			try (FileSystem zipfs = FileSystems.newFileSystem(tempFile, null)) { 
				Path textFile = zipfs.getPath("test/hello.txt"); 
				testStartsWith(textFile, zipfs.getPath("test")); 
				testStartsWith(textFile, Paths.get("test")); 
				testEndsWith(textFile, zipfs.getPath("hello.txt")); 
				testEndsWith(textFile, Paths.get("hello.txt")); 
			} 
		} finally { 
			Files.delete(tempFile); 
		} 
	} 

	static void testStartsWith(Path path, Path prefix) { 
		System.out.printf( 
				"\"%s\" (%s) starts with \"%s\" (%s)?%n", 
				path, 
				getProviderName(path), 
				prefix, 
				getProviderName(prefix)); 
		try { 
			System.out.println(path.startsWith(prefix)); 
		} catch (ProviderMismatchException e) { 
			e.printStackTrace(System.out); 
		} 
		System.out.println(); 
	} 

	static void testEndsWith(Path path, Path suffix) { 
		System.out.printf( 
				"\"%s\" (%s) ends with \"%s\" (%s)?%n", 
				path, 
				getProviderName(path), 
				suffix, 
				getProviderName(suffix)); 
		try { 
			System.out.println(path.endsWith(suffix)); 
		} catch (ProviderMismatchException e) { 
			e.printStackTrace(System.out); 
		} 
		System.out.println(); 
	} 

	static String getProviderName(Path path) { 
		return path.getFileSystem().provider().getClass().getName(); 
	} 


}
