java/xmlreader/src/main/java/be/bosa/dt/best/xmlreader/AbstractXMLReader.java
/**
	 * Check if there is a file for a region.
	 * File names should follow the pattern "Region""Suffix""...""ext"
	 * 
	 * @param indir input directory
	 * @param region region
	 * @param type object type
	 * @param ext file extension
	 * @return path to file
	 * @throws IOException when no matching file was found 
	 */
Check if there is a file for a region.


Check if there is a file for a region .
protected Path checkFile(Path indir, BestRegion region, BestType type, String ext) throws IOException {
		String start = (region.getName() + type.getName()).toLowerCase();
		Path xml = Files.list(indir).filter(p -> {
			String name = p.getFileName().toString().toLowerCase();
			return name.startsWith(start) && name.endsWith(ext);
		}).findFirst().orElseThrow(() -> new IOException("No file starting with " + start + " found"));
		if (Files.isRegularFile(xml) && Files.isReadable(xml)) {
			return xml;
		}
		throw new IOException("File not readable");
	}
protected Path checkFile ( Path indir , BestRegion region , BestType type , String ext ) throws IOException { String start = ( region . getName ( ) + type . getName ( ) ) . toLowerCase ( ) ; Path xml = Files . list ( indir ) . filter ( p -> { String name = p . getFileName ( ) . toString ( ) . toLowerCase ( ) ; return name . startsWith ( start ) && name . endsWith ( ext ) ; } ) . findFirst ( ) . orElseThrow ( ( ) -> new IOException ( "No file starting with " + start + " found" ) ) ; if ( Files . isRegularFile ( xml ) && Files . isReadable ( xml ) ) { return xml ; } throw new IOException ( "File not readable" ) ; }
Check if there is a file for a region.
Check if there is a file for a region .