Package java.io

Examples of java.io.File.createNewFile()


  private BufferedWriter getBufferedWriter() throws IOException {
    File file = new File(path, name + "."
        + LogFactory.dayDateFormat.format(new Date()) + ".txt");
    boolean ret = false;
    if (!file.exists()) {
      ret = file.createNewFile();
    } else {
      ret = true;
    }
    if (ret)
      return new BufferedWriter(new FileWriter(file, true));
View Full Code Here


  if (summaryFile.exists() && !overwrite) {
      throw new IOException(
        "Summary file already exists: " + summaryFile.getName()); //$NON-NLS-1$
  }
  try {
      summaryFile.createNewFile();
  } catch (IOException ioe) {
      TestLogger.log("Error creating new summary file: "
        + summaryFile.getAbsolutePath());
      throw ioe;
  }
View Full Code Here

      throw new IOException(
        "Summary file already exists: " + summaryFile.getName()); //$NON-NLS-1$
  }

  try {
      summaryFile.createNewFile();
  } catch (IOException e) {
      System.err
        .println("Failed to create summary file at: " + summaryFile.getAbsolutePath()); //$NON-NLS-1$
      throw new IOException(
        "Failed to create summary file at: " + summaryFile.getAbsolutePath() + ": " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
View Full Code Here

          BufferedWriter out = new BufferedWriter(fstream);

  if (!exists) {

          try {
              summaryFile.createNewFile();
          } catch (IOException e) {
              System.err
                .println("Failed to create overall summary file at: " + summaryFile.getAbsolutePath()); //$NON-NLS-1$
              throw new IOException(
                "Failed to create overall summary file at: " + summaryFile.getAbsolutePath() + ": " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
View Full Code Here

        BufferedWriter out = new BufferedWriter(fstream);

        if (!exists) {

            try {
          summaryFile.createNewFile();
            } catch (IOException e) {
          System.err
        .println("Failed to create overall summary error file at: " + summaryFile.getAbsolutePath()); //$NON-NLS-1$
          throw new IOException(
        "Failed to create overall summary error file at: " + summaryFile.getAbsolutePath() + ": " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
View Full Code Here

      if (fis == null || fis.available() < 0) {
        return;
      }
      fl = new File(this.fullWorkingPath + fileName);

      if (!fl.createNewFile()) {
        throw new CvFileException(CvFileException.COULD_NOT_CREATE_DIRECTORY, "Could not create file");
      }

      fos = new FileOutputStream(fl);
View Full Code Here

        assertEquals(0, testFile.length());
    }

    public void testStoreWithExistingFile() throws Exception {
        File testFile = new File(ROOT_DIR, TEST_FILENAME);
        testFile.createNewFile();

        assertTrue(testFile.exists());
        assertEquals(0, testFile.length());

        assertTrue(client.storeFile(TEST_FILENAME, new ByteArrayInputStream(
View Full Code Here

    }

    public void testStoreUniqueWithCompletePath() throws Exception {
        TEST_DIR.mkdirs();
        File existingFile = new File(TEST_DIR, "existingFile.txt");
        existingFile.createNewFile();

        assertTrue(client.storeUniqueFile("foo/bar/existingFile.txt",
                new ByteArrayInputStream(testData)));

        doAssertOfUniqueFile(client, ROOT_DIR);
View Full Code Here

    protected abstract ISettingsFileSearchStrategy getStrategy();

    protected File createSettingsFile(File dir) {
        File file = new File(dir, Settings.DEFAULT_SETTINGS_FILE);
        try {
            file.createNewFile();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        file.deleteOnExit();
        return file;
View Full Code Here


  private static void makeEmpty( final String filename ) throws IOException {
    final File file = new File( filename );
    if ( file.exists() && !file.delete() ) throw new IOException( "Cannot delete file " + file );
    file.createNewFile();
  }

  /**
   * Closes this pass, releasing all resources.
   */
 
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.