当前位置: 首页>>代码示例>>Java>>正文


Java FileUtil.createTempFile方法代码示例

本文整理汇总了Java中com.intellij.openapi.util.io.FileUtil.createTempFile方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtil.createTempFile方法的具体用法?Java FileUtil.createTempFile怎么用?Java FileUtil.createTempFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.util.io.FileUtil的用法示例。


在下文中一共展示了FileUtil.createTempFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUp

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
  super.setUp();
  Random random = new Random();
  for (int i = 0; i < 1000; i++) {
    byte[] bytes = new byte[1000];
    random.nextBytes(bytes);
    String key = new String(bytes, CharsetToolkit.UTF8_CHARSET);
    myKeys.add(key);
  }
  for (int i = 0; i < 10; i++) {
    PersistentHashMap<String, Record> map = createMap(FileUtil.createTempFile("persistent", "map" + i));
    myMaps.add(map);
  }
  PagedFileStorage.StorageLockContext storageLockContext = new PagedFileStorage.StorageLockContext(false);
  myEnumerator = new PersistentStringEnumerator(FileUtil.createTempFile("persistent", "enum"), storageLockContext);

  myThreadPool = Executors.newFixedThreadPool(myMaps.size() + 1);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:PersistenceStressTest.java

示例2: makeAndAddLibraryJar

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
private static void makeAndAddLibraryJar(final VirtualFile virtualFile,
                                         final File zipFile,
                                         final String pluginName,
                                         final ZipOutputStream zos,
                                         final Set<String> usedJarNames,
                                         final ProgressIndicator progressIndicator,
                                         final String preferredName) throws IOException {
  File libraryJar = FileUtil.createTempFile(TEMP_PREFIX, JAR_EXTENSION);
  libraryJar.deleteOnExit();
  ZipOutputStream jar = null;
  try {
    jar = new JarOutputStream(new BufferedOutputStream(new FileOutputStream(libraryJar)));
    ZipUtil.addFileOrDirRecursively(jar, libraryJar, VfsUtilCore.virtualToIoFile(virtualFile), "",
                                    createFilter(progressIndicator, FileTypeManager.getInstance()), null);
  }
  finally {
    if (jar != null) jar.close();
  }
  final String jarName =
    getLibraryJarName(virtualFile.getName() + JAR_EXTENSION, usedJarNames, preferredName == null ? null : preferredName + JAR_EXTENSION);
  ZipUtil.addFileOrDirRecursively(zos, zipFile, libraryJar, getZipPath(pluginName, jarName), createFilter(progressIndicator, null), null);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:PrepareToDeployAction.java

示例3: testAutoDetectEmptyFile

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
public void testAutoDetectEmptyFile() throws IOException {
  File dir = createTempDirectory();
  File file = FileUtil.createTempFile(dir, "x", "xxx_xx_xx", true);
  VirtualFile virtualFile = getVirtualFile(file);
  assertNotNull(virtualFile);
  assertEquals(FileTypes.UNKNOWN, virtualFile.getFileType());
  PsiFile psi = getPsiManager().findFile(virtualFile);
  assertTrue(psi instanceof PsiBinaryFile);
  assertEquals(FileTypes.UNKNOWN, virtualFile.getFileType());

  setBinaryContent(virtualFile, "xxxxxxx".getBytes(CharsetToolkit.UTF8_CHARSET));
  assertEquals(FileTypes.PLAIN_TEXT, virtualFile.getFileType());
  PsiFile after = getPsiManager().findFile(virtualFile);
  assertNotSame(psi, after);
  assertFalse(psi.isValid());
  assertTrue(after.isValid());
  assertTrue(after instanceof PsiPlainTextFile);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:FileTypesTest.java

示例4: createFromTempFile

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
public static FileContent createFromTempFile(Project project, String name, String ext, @NotNull byte[] content) throws IOException {
  File tempFile = FileUtil.createTempFile(name, "." + ext);
  if (content.length != 0) {
    FileUtil.writeToFile(tempFile, content);
  }
  tempFile.deleteOnExit();
  final LocalFileSystem lfs = LocalFileSystem.getInstance();
  VirtualFile file = lfs.findFileByIoFile(tempFile);
  if (file == null) {
    file = lfs.refreshAndFindFileByIoFile(tempFile);
  }
  if (file != null) {
    return new FileContent(project, file);
  }
  throw new IOException("Can not create temp file for revision content");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:FileContent.java

示例5: getFile

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
@Nullable
private synchronized File getFile() {
  if (myFile == null) {
    try {
      final File tempFile = FileUtil.createTempFile("idea_test_", ".out");
      if (tempFile.exists()) {
        myFile = tempFile;
        return myFile;
      }
    }
    catch (IOException e) {
      LOG.error(e);
      return null;
    }
  }
  return myFile;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:CompositePrintable.java

示例6: testBadFileName

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
public void testBadFileName() throws Exception {
  if (!SystemInfo.isUnix) {
    System.err.println(getName() + " skipped: " + SystemInfo.OS_NAME);
    return;
  }

  final File dir = FileUtil.createTempDirectory("test.", ".dir");
  final File file = FileUtil.createTempFile(dir, "test\\", "\\txt", true);

  final VirtualFile vDir = myFS.refreshAndFindFileByIoFile(dir);
  assertNotNull(vDir);
  assertEquals(0, vDir.getChildren().length);

  ((VirtualFileSystemEntry)vDir).markDirtyRecursively();
  vDir.refresh(false, true);

  final VirtualFile vFile = myFS.refreshAndFindFileByIoFile(file);
  assertNull(vFile);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:LocalFileSystemTest.java

示例7: updateStatus

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
/**
 * Post on twitter media and text from panel
 * @param panel shown to user and used to provide data to post 
 */
public static void updateStatus(StudyTwitterUtils.TwitterDialogPanel panel, Twitter twitter) throws IOException, TwitterException {
  StatusUpdate update = new StatusUpdate(panel.getMessage());
  InputStream e = panel.getMediaSource();
  if (e != null) {
    File imageFile = FileUtil.createTempFile("twitter_media", panel.getMediaExtension());
    FileUtil.copy(e, new FileOutputStream(imageFile));
    update.media(imageFile);
  }

  twitter.updateStatus(update);
  BrowserUtil.browse("https://twitter.com/");
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:17,代码来源:StudyTwitterUtils.java

示例8: createTempFile

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
private File createTempFile( byte[] bytes )
{
  try
  {
    File file = FileUtil.createTempFile( new File( PathManager.getTempPath() ), "manifoldHotSwap", ".class" );
    FileUtil.writeToFile( file, bytes );
    return file;
  }
  catch( IOException e )
  {
    throw new RuntimeException( e );
  }
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:14,代码来源:HotSwapComponent.java

示例9: testFileLength

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
public void testFileLength() throws Exception {
  File file = FileUtil.createTempFile("test", "txt");
  FileUtil.writeToFile(file, "hello");
  VirtualFile virtualFile = myFS.refreshAndFindFileByIoFile(file);
  assertNotNull(virtualFile);
  String s = VfsUtilCore.loadText(virtualFile);
  assertEquals("hello", s);
  assertEquals(5, virtualFile.getLength());

  FileUtil.writeToFile(file, "new content");
  ((PersistentFSImpl)PersistentFS.getInstance()).cleanPersistedContents();
  s = VfsUtilCore.loadText(virtualFile);
  assertEquals("new content", s);
  assertEquals(11, virtualFile.getLength());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:LocalFileSystemTest.java

示例10: createTempFiles

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
protected void createTempFiles(JavaParameters javaParameters) {
  try {
    myWorkingDirsFile = FileUtil.createTempFile("idea_working_dirs_" + getFrameworkId(), ".tmp");
    myWorkingDirsFile.deleteOnExit();
    javaParameters.getProgramParametersList().add("@[email protected]" + myWorkingDirsFile.getAbsolutePath());
    
    myTempFile = FileUtil.createTempFile("idea_" + getFrameworkId(), ".tmp");
    myTempFile.deleteOnExit();
    passTempFile(javaParameters.getProgramParametersList(), myTempFile.getAbsolutePath());
  }
  catch (Exception e) {
    LOG.error(e);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:JavaTestFrameworkRunnableState.java

示例11: setUp

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
@Before
public void setUp() throws IOException {
  myFile = FileUtil.createTempFile("vmoptions.", ".txt");
  writeFile("-Xmx512m\n" +
            "-XX:MaxPermSize=128m");
  VMOptions.setTestFile(myFile.getPath());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:VMOptionsTest.java

示例12: setUp

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
  super.setUp();
  myFile = FileUtil.createTempFile("persistent", "map");
  myDataFile = new File(myFile.getParentFile(), myFile.getName() + PersistentHashMap.DATA_FILE_EXTENSION);
  myMap = new PersistentHashMap<String, String>(myFile, new EnumeratorStringDescriptor(), new EnumeratorStringDescriptor());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:PersistentMapTest.java

示例13: downloadAtomically

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
/**
 * Downloads content of {@code url} to {@code outputFile}.
 * {@code outputFile} won't be modified in case of any I/O download errors.
 *
 * @param indicator   progress indicator
 * @param url         url to download
 * @param outputFile  output file
 */
public static void downloadAtomically(@Nullable ProgressIndicator indicator,
                                      @NotNull String url,
                                      @NotNull File outputFile,
                                      @NotNull String userName,
                                      @NotNull String repositoryName) throws IOException
{
  String tempFileName = String.format("github-%s-%s-%s", userName, repositoryName, outputFile.getName());
  File tempFile = FileUtil.createTempFile(tempFileName + "-", ".tmp");
  DownloadUtil.downloadAtomically(indicator, url, outputFile, tempFile);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:GithubDownloadUtil.java

示例14: testAutoDetectedWhenDocumentWasCreated

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
public void testAutoDetectedWhenDocumentWasCreated() throws IOException {
  File dir = createTempDirectory();
  File file = FileUtil.createTempFile(dir, "x", "xxx_xx_xx", true);
  FileUtil.writeToFile(file, "xxx xxx xxx xxx");
  VirtualFile virtualFile = getVirtualFile(file);
  assertNotNull(virtualFile);
  Document document = FileDocumentManager.getInstance().getDocument(virtualFile);
  assertNotNull(document);
  assertEquals(FileTypes.PLAIN_TEXT, virtualFile.getFileType());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:FileTypesTest.java

示例15: createMessageFile

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
/**
 * Create a file that contains the specified message
 *
 * @param root    a git repository root
 * @param message a message to write
 * @return a file reference
 * @throws IOException if file cannot be created
 */
private File createMessageFile(VirtualFile root, final String message) throws IOException {
  // filter comment lines
  File file = FileUtil.createTempFile(GIT_COMMIT_MSG_FILE_PREFIX, GIT_COMMIT_MSG_FILE_EXT);
  file.deleteOnExit();
  @NonNls String encoding = GitConfigUtil.getCommitEncoding(myProject, root);
  Writer out = new OutputStreamWriter(new FileOutputStream(file), encoding);
  try {
    out.write(message);
  }
  finally {
    out.close();
  }
  return file;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:GitCheckinEnvironment.java


注:本文中的com.intellij.openapi.util.io.FileUtil.createTempFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。