当前位置 : 主页 > 大数据 > 区块链 >

PathUtil

来源:互联网 收集:自由互联 发布时间:2021-06-22
public String getParentPath( final String originalPath) { boolean isSplitRequired = true ; int lastSlashIndex = originalPath.lastIndexOf("/" ); if (lastSlashIndex == -1 lastSlashIndex == 0 ) { isSplitRequired = false ; } return isSplitRequi
    public String getParentPath(final String originalPath) {
        boolean isSplitRequired = true;
        
        int lastSlashIndex = originalPath.lastIndexOf("/");
        if (lastSlashIndex == -1 && lastSlashIndex == 0) {
            isSplitRequired = false;
        }
        
        return isSplitRequired ?
                originalPath.substring(0,lastSlashIndex) : originalPath;
    }
网友评论