Package java.io

Examples of java.io.File.createNewFile()


public class DeleteOnCloseFileInputStreamTest extends TestCase {
  public void testIt() throws Exception {
    String property = System.getProperty("java.io.tmpdir");
    File tempFile = new File(property, getClass().getName());
    assertTrue(tempFile.createNewFile());
    DeleteOnCloseFileInputStream is = new DeleteOnCloseFileInputStream(tempFile);
    is.close();
    assertFalse("file was not deleted.", tempFile.exists());
  }
}
View Full Code Here


        if (outputFile != null) {
            File oFile = new File(outputFile);
           
            try {
                if(!oFile.exists()){
                    oFile.createNewFile();
                }
                if (oFile.canWrite()) {
                    outWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(oFile)));
                }
            } catch (FileNotFoundException e) {
View Full Code Here

        }
        if (errFile != null) {
            File eFile = new File(errFile);
            try {
                if(!eFile.exists()){
                    eFile.createNewFile();
                }
                if (eFile.canWrite()) {
                    errWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(eFile)));
                }
            } catch (FileNotFoundException e) {
View Full Code Here

    }
    // So, f is a file
    if (dest.isDirectory()) {
      // Create a new file of that name in the empty directory
      File newFile = new File(dest, src.getName());
      newFile.createNewFile();
      // Use copy in the last case : file to file
      copy(src,newFile);
      return;
    }
    try {
View Full Code Here

     
      first_run = true;
     
      try {
     
        config_file.createNewFile();
     
      } catch( Throwable cause ) {
       
        throw new JMuleCoreException( cause );
       
View Full Code Here

         File lock = null;
         String lockName = null;
         if (this.lockExtention != null) {
            lockName = fileName + this.lockExtention;
            lock = new File(dir, lockName);
            lock.createNewFile();
         }
         log.info("storing file '" + fileName + "' on directory '" + dir + "'");

         File[] files = null;
         long numChunks = 0L;
View Full Code Here

     
      // now some which should fail:
      // existing file but not a directory
      File file = new File(this.dirName);
      try {
         file.createNewFile();
      }
      catch (IOException ex) {
         assertTrue("could not create the file '" + this.dirName + "'", false);
      }
     
View Full Code Here

      try {
         file = new File(this.dirName);
         boolean ret = file.mkdir();
         assertTrue("could not create directory '" + this.dirName + "'", ret);
         file = new File(this.dirNameSent);
         file.createNewFile();
      }
      catch (IOException ex) {
         assertTrue("could not create the file '" + this.dirNameSent + "'", false);
      }
     
View Full Code Here

      try {
         File lock = null;
         if (lockExt != null) {
            String tmp = filename + lockExt.substring(1);
            lock = new File(tmp);
            boolean ret = lock.createNewFile();
            assertTrue("could not create lock file '" + tmp + "'", ret);
            int upd = this.updateInterceptor.waitOnUpdate(timeToWait);
            assertEquals("when writing lock file should not update", 0, upd);
         }
         else
View Full Code Here

     
      // now some which should fail:
      // existing file but not a directory
      File file = new File(this.pollerDirName);
      try {
         file.createNewFile();
      }
      catch (IOException ex) {
         assertTrue("could not create the file '" + this.pollerDirName + "'", false);
      }
     
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.