src/java.base/share/classes/sun/nio/fs/AbstractFileTypeDetector.java

Print this page
rev 12244 : 8129632: (fs) Files.probeContentType returns null on Mac OS X
Summary: Append a Uniform Type Identifier-based FileType Detector for Mac OS X
Reviewed-by: XXX

*** 1,7 **** /* ! * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 39,48 **** --- 39,60 ---- { protected AbstractFileTypeDetector() { super(); } + // Get the extension of a file name. + protected static String getExtension(String name) { + String ext = ""; + if (name != null && !name.isEmpty()) { + int dot = name.indexOf('.'); + if ((dot >= 0) && (dot < name.length() - 1)) { + ext = name.substring(dot + 1); + } + } + return ext; + } + /** * Invokes the appropriate probe method to guess a file's content type, * and checks that the content type's syntax is valid. */ @Override