org.openide.filesystems.FileUtil.getExtension()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(7.2k)|赞(0)|评价(0)|浏览(96)

本文整理了Java中org.openide.filesystems.FileUtil.getExtension()方法的一些代码示例,展示了FileUtil.getExtension()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtil.getExtension()方法的具体详情如下:
包路径:org.openide.filesystems.FileUtil
类名称:FileUtil
方法名:getExtension

FileUtil.getExtension介绍

[英]Gets the extension of a specified file name. The extension is everything after the last dot.
[中]

代码示例

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-javafx2-project

@Override
public boolean accept(File f) {
  if (f.isDirectory()) {
    return true;
  }
  String extension;
  switch (type) {
    default:
    case FXML: extension = FXML_FILE_EXTENSION;
      break;
    case JAVA: extension = JAVA_FILE_EXTENSION;
      break;
    case CSS: extension = CSS_FILE_EXTENSION;
      break;
  }
  return ("." + FileUtil.getExtension(f.getName())).equals(extension); // NOI18N
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd

public String getTargetName() {
  String documentName = documentNameTextField.getText().trim();
  
  if ( documentName.length() == 0){
    return null;
  }
  else {
    String docExt = FileUtil.getExtension( documentName );
    if (docExt.length() == 0 && expectedExtension.length() > 0) {
      documentName += '.' + expectedExtension;
    } else {
      assert docExt.equals(expectedExtension);
    }
    return documentName;
  }
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-visualweb-project-jsf

private File findUniqueFile(File old) {
  int count = 1;
  String fileName = old.getName();
  String extension = FileUtil.getExtension(fileName);
  String baseName = fileName.substring(0, fileName.lastIndexOf(extension) - 1);
  String testName = fileName;
  File dir = old.getParentFile();
  File newFile = null;
  while(newFile == null) {
    newFile = new File(dir, testName);
    if (!newFile.exists())
      return newFile;
    newFile = null;
    testName = baseName + "_" + count++ + "." + extension;  // NOI18N
  }
  return newFile;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-utils

@Override
protected boolean mimeAccept(File f) {
  if (FileUtil.getExtension(f.getName()).length() == 0) {
    return MIMENames.HEADER_MIME_TYPE.equals(MIMESupport.getSourceFileMIMEType(f));
  }
  return super.mimeAccept(f);
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-utils

@Override
protected boolean mimeAccept(File f) {
  if (FileUtil.getExtension(f.getName()).length() == 0) {
    return MIMENames.HEADER_MIME_TYPE.equals(MIMESupport.getSourceFileMIMEType(f));
  }
  return super.mimeAccept(f);
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-completion

private static boolean isHeaderFileWoExt(FileObject pathname) {
  if (FileUtil.getExtension(pathname.getNameExt()).length() == 0) {
    return MIMENames.HEADER_MIME_TYPE.equals(MIMESupport.getSourceFileMIMEType(pathname));
  }
  return false;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-css-prep

@CheckForNull
public static File resolveTarget(FileObject webRoot, List<Pair<String, String>> mappings, File source) {
  File root = FileUtil.toFile(webRoot);
  String name = source.getName();
  String extension = FileUtil.getExtension(name);
  if (!extension.isEmpty()) {
    name = name.substring(0, name.length() - (extension.length() + 1));
  }
  return resolveTarget(root, mappings, source, name);
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-utils

/**
 * tries to detect mime type by file path extension only
 * more precise (but possibly slower) method is @see getSourceMIMEType(File file).
 * This method can not detect header files without extensions, while
 * @see getSourceMIMEType(File file) can
 * @param filePathOrName path or name to check
 * @return one of cnd source mime types (@see MIMENames.SOURCE_MIME_TYPES) or null
 */
public static String getKnownSourceFileMIMETypeByExtension(String filePathOrName) {
  String fileName = CndPathUtilities.getBaseName(filePathOrName);
  // check by known file extension
  String ext = FileUtil.getExtension(fileName);
  for (String mimeType : SOURCE_MIME_TYPES) {
    if (MIMEExtensions.isRegistered(mimeType, ext)) {
      return mimeType;
    }
  }
  return null;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-utils

/**
 * tries to detect mime type by file path extension only
 * more precise (but possibly slower) method is @see getSourceMIMEType(File file).
 * This method can not detect header files without extensions, while
 * @see getSourceMIMEType(File file) can
 * @param filePathOrName path or name to check
 * @return one of cnd source mime types (@see MIMENames.SOURCE_MIME_TYPES) or null
 */
public static String getKnownBinaryFileMIMETypeByExtension(String filePathOrName) {
  String fileName = CndPathUtilities.getBaseName(filePathOrName);
  // check by known file extension
  String ext = FileUtil.getExtension(fileName);
  for (String mimeType : BINARY_MIME_TYPES) {
    if (MIMEExtensions.isRegistered(mimeType, ext)) {
      return mimeType;
    }
  }
  return null;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-utils

@Override
protected boolean mimeAccept(FileObject fo) {
  if (fo != null) {
    if (fo.isValid()) {
      return MIMENames.SHELL_MIME_TYPE.equals(FileUtil.getMIMEType(fo, MIMENames.SHELL_MIME_TYPE));
    } else {
      return MIMEExtensions.isRegistered(MIMENames.SHELL_MIME_TYPE, FileUtil.getExtension(fo.getNameExt()));
    }
  }
  return false;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd

@Override
protected FileObject createFromTemplate(FileObject template, FileObject folder, String name, Map<String, Object> parameters) throws IOException {
  String ext = FileUtil.getExtension(name);
  if (ext.length() != 0) {
    name = name.substring(0, name.length() - ext.length() - 1);

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd

String docExt = FileUtil.getExtension( documentName );

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-makeproject

private void updateExtensionList() {
  Set<String> h = MakeProject.createExtensionSet();
  Set<String> c = MakeProject.createExtensionSet();
  Set<String> cpp = MakeProject.createExtensionSet();
  for (Item item : getProjectItems()) {
    String itemName = item.getName();
    String ext = FileUtil.getExtension(itemName);
    if (ext.length() > 0) {
      if (!h.contains(ext) && !c.contains(ext) && !cpp.contains(ext)) {
        if (MIMEExtensions.isRegistered(MIMENames.HEADER_MIME_TYPE, ext)) {
          h.add(ext);
        } else if (MIMEExtensions.isRegistered(MIMENames.C_MIME_TYPE, ext)) {
          c.add(ext);
        } else if (MIMEExtensions.isRegistered(MIMENames.CPLUSPLUS_MIME_TYPE, ext)) {
          cpp.add(ext);
        }
      }
    }
  }
  MakeProject makeProject = (MakeProject) getProject();
  if (makeProject != null) {
    makeProject.updateExtensions(c, cpp, h);
  }
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-visualweb-project-jsf

String ext = FileUtil.getExtension(name);
if (ext.length() > 0)
  name = name.substring(0, name.lastIndexOf(ext) - 1);

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-source

ext = FileUtil.getExtension(name);
if (ext.length() != 0) {
  name = name.substring(0, name.length() - ext.length() - 1);

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd

@Override
protected void doStoreSettings(WizardDescriptor settings) {
  String table = (CppSettings.findObject(CppSettings.class, true)).getReplaceableStringsTable();
  table +="\nCLASSNAME=" + getGui().getFormName(); // NOI18N
  if (getGui().getHeaderFileName() != null) {
    table +="\nDEFAULT_HEADER_EXT=" + FileUtil.getExtension(getGui().getHeaderFileName()); // NOI18N
    table +="\nWIDGETCLASSNAME=" + getGui().getFormType().widgetClassName; // NOI18N
  }
  (CppSettings.findObject(CppSettings.class, true)).setReplaceableStringsTable(table);
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-makeproject

additionalDep = null;
String name = items[i].getName();
String extension = FileUtil.getExtension(name);
name = name.substring(0, name.length() - (extension.isEmpty() ? 0 : extension.length() + 1));
String nomainTarget;

相关文章