當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。