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

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

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

FileUtil.createData介绍

[英]Returns FileObject for a data file. If such a data file does not exist then it is created, including any necessary but nonexistent parent folders. Note that if this operation fails it may have succeeded in creating some of the necessary parent folders.
[中]返回数据文件的FileObject。如果这样的数据文件不存在,则会创建它,包括任何必要但不存在的父文件夹。请注意,如果此操作失败,它可能已成功创建一些必要的父文件夹。

代码示例

代码示例来源:origin: org.netbeans.api/org-openide-filesystems

final String relativePath = getRelativePath(folder, data);
try {
  retval = FileUtil.createData(folderFo,relativePath);        
} catch (IOException ex) {
  retval = FileUtil.createData(folderFo,relativePath);

代码示例来源:origin: org.netbeans.api/org-openide-filesystems

/** Creates a file object that will mask the given file.
* @param fs filesystem to work on
* @param res resource name of the file
* @exception IOException if it fails
*/
void maskFile(FileSystem fs, String res) throws IOException {
  FileObject where = findResourceOn(fs, fs.getRoot().getPath());
  FileUtil.createData(where, res + MASK);
}

代码示例来源:origin: org.netbeans.api/org-openide-filesystems

} else {
  FileObject fd = createData(fo, name);
  FileLock lock = fd.lock();

代码示例来源:origin: org.netbeans.api/org-openide-filesystems

FileUtil.createData(root(simple), fullName);

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

private File getLogFile(String timestamp) throws IOException {
  File f = new File(directory, prefix + timestamp + suffix);
  try {
    FileUtil.createData(f);
  } catch (IOException ex) {
    // this can happen when directory is RO for netbeans
    LOGGER.log(Level.INFO, null, ex);
    return null;
  }
  return f;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-junit-ant-ui

private Properties getProjectProperties(FileObject projectDir) throws IOException {
    FileObject projectProperties = FileUtil.createData(projectDir, AntProjectHelper.PROJECT_PROPERTIES_PATH);
    InputStream propertiesIS = projectProperties.getInputStream();
    Properties props = new Properties();
    props.load(propertiesIS);
    propertiesIS.close();
    return props;
  }
}

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

private static FileObject createFileObject(FileObject dir, String relToDir) throws IOException {
  FileObject createdFO = dir.getFileObject(relToDir);
  if (createdFO != null) {
    throw new IllegalArgumentException("File " + createdFO + " already exists."); // NOI18N
  }
  createdFO = FileUtil.createData(dir, relToDir);
  return createdFO;
}

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

public void run() throws IOException {
    FileObject rakeTasksFile = projectDir.getFileObject(RAKE_D_OUTPUT);
    if (rakeTasksFile != null) {
      rakeTasksFile.delete();
    }
    rakeTasksFile = FileUtil.createData(projectDir, RAKE_D_OUTPUT);
    OutputStream os = rakeTasksFile.getOutputStream();
    Writer writer = new BufferedWriter(new OutputStreamWriter(os));
    try {
      writer.write(rakeDOutput);
    } finally {
      writer.close();
    }
  }
});

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

@Override
  public void run(FileSystem layer) throws IOException {
    FileObject fo = FileUtil.createFolder(layer.getRoot(), "Windows2/Modes");
    for (Map.Entry<String, String> entry : newModes.entrySet()) {
      FileObject wsmode = FileUtil.createData(fo, entry.getKey() + ".wsmode");
      OutputStream os = wsmode.getOutputStream();
      try {
        os.write(entry.getValue().getBytes("UTF-8"));
      } finally {
        os.close();
      }
    }
  }   
}, files));

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

public void run() throws IOException {
    FileObject detailForm = FileUtil.createData(jsfRoot, name);//NOI18N
    FileLock lock = detailForm.lock();
    try {
      BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(detailForm.getOutputStream(lock), encoding));
      bw.write(content);
      bw.close();
    }
    finally {
      lock.releaseLock();
    }
  }
});

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-java-source-base

private void create() throws IOException {
    File parent = f.getParentFile();
    FileObject parentFo = FileUtil.createFolder(parent);
    assert parentFo != null;
    FileObject template = FileUtil.getConfigFile("Templates/Classes/Empty.java");     //NOI18N
    FileObjectFromTemplateCreator creator = Lookup.getDefault().lookup(FileObjectFromTemplateCreator.class);
    if (template == null || creator == null) {
      FileUtil.createData(parentFo, f.getName());
      return;
    }
    FileObject newFO = creator.create(template, parentFo, f.getName());
    assert newFO != null;
  }
}

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

private static void createSeparator (
  FileObject      folder,
  String          name,
  int position
) throws IOException {
  FileObject separator = FileUtil.createData(folder, name + ".instance");
  separator.setAttribute ("instanceClass", "javax.swing.JSeparator");
  separator.setAttribute("position", position);
}

代码示例来源:origin: it.tidalwave.blueargyle/it-tidalwave-uniformity-archive

/*******************************************************************************************************************
 * 
 *
 * 
 ******************************************************************************************************************/
@PostConstruct
public void initialize() // FIXME: private
 throws IOException
 {
  log.info("initialize()");  
  persistenceFile = FileUtil.createData(FileUtil.getConfigRoot(), "Archive/UniformityMeasurements.txt");
  log.info(">>>> persistenceFile: {}", persistenceFile.getPath());
  loadArchive();
 }

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

protected final FileObject getPropertyFile() throws IOException {
  if (propertiesFile == null) {
    FileObject projectDirectory = getProject().getProjectDirectory();
    propertiesFile = FileUtil.createData(projectDirectory, propertyPath);
  }
  return propertiesFile;
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide

/** Creates a file object that will mask the given file.
* @param fs filesystem to work on
* @param res resource name of the file
* @exception IOException if it fails
*/
void maskFile (FileSystem fs, String res) throws IOException {
  FileObject where = findResourceOn (fs,fs.getRoot().getPath ());
  FileUtil.createData (where, res + MASK);        
}

代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide

/** Creates a file object that will mask the given file.
* @param fs filesystem to work on
* @param res resource name of the file
* @exception IOException if it fails
*/
void maskFile (FileSystem fs, String res) throws IOException {
  FileObject where = findResourceOn (fs,fs.getRoot().getPath ());
  FileUtil.createData (where, res + MASK);        
}

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

public void run() throws IOException {
  FileObject fo = FileUtil.createData(rootFo, fullPath);
  FileLock lock = fo.lock();
  try {
    OutputStream os = fo.getOutputStream(lock);
    writer.writeTo(os);
  } finally {
    lock.releaseLock();
  }
  }
} );

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

@Override
  public void run() throws IOException {
    FileObject prjDir = getProject().getProjectDirectory();
    FileObject bundleFO = FileUtil.createData(prjDir, bundlePath);
    EditableProperties ep = Util.loadProperties(bundleFO);
    ep.setProperty(key, value);
    Util.storeProperties(bundleFO, ep);
  }
}

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

public static void saveToFile(final @NonNull FileObject dirFO, final @NonNull String relativePath, final @NonNull EditableProperties ep) throws IOException {
  assert dirFO.isFolder();
  FileObject f = dirFO.getFileObject(relativePath);
  final FileObject propsFO;
  if(f == null) {
    propsFO = FileUtil.createData(dirFO, relativePath);
    assert propsFO != null : "FU.cD must not return null; called on " + dirFO + " + " + relativePath; // #50802  // NOI18N
  } else {
    propsFO = f;
  }
  saveToFile(propsFO, ep);
}

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

@Override
  public void run() throws IOException {
    FileObject target = FileUtil.createData(getProject().getProjectDirectory(), path);
    if (tokens == null) {
      copyByteAfterByte(content, target);
    } else {
      copyAndSubstituteTokens(content, target, tokens);
    }
    // #129446: form editor doesn't work sanely unless you do this:
    if (target.hasExt("form")) { // NOI18N
      FileObject java = FileUtil.findBrother(target, "java"); // NOI18N
      if (java != null) {
        java.setAttribute("justCreatedByNewWizard", true); // NOI18N
      }
    } else if (target.hasExt("java") && FileUtil.findBrother(target, "form") != null) { // NOI18N
      target.setAttribute("justCreatedByNewWizard", true); // NOI18N
    }
  }
}

相关文章