Demos and Usage of java.io.File.createNewFile()


   1: import java.io.File;
   2: import java.io.IOException;
   3:         ...
   4:     {
   5:       File f = new File( s );
   6: 
   7:         ...
   8:         {
   9:           f.createNewFile();
  10:           System.out.println( "create new file " + s );

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.IOException;
   4:         ...
   5:             String fileName = Properties.getProperty(PropertiesHelper.DATA_FILE);
   6:             File dataFile = new File(fileName);
   7:             if (!dataFile.exists()) {
   8:         ...
   9:                 try {
  10:                     dataFile.createNewFile();
  11:                 } catch (IOException e) {

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.PrintStream;
   4:         ...
   5:     public static void mblLog(String text) {
   6:         File tmpFile = new File("E:\\idea-log.txt");
   7:         
   8:         ...
   9:             if ( !tmpFile.exists() )
  10:                 tmpFile.createNewFile();
  11:             

View Full Code Here
   1: 
   2: import java.io.File;
   3: 
   4:         ...
   5: public class ListFilesInDirectoryTest extends TestCase {
   6:     private File[] expectedFiles =
   7:         ...
   8:         new File[] {
   9:             new File("c:/unittest/tmp/file1.xml"),
  10:         ...
  11:             File newFile = expectedFiles[i];
  12:             newFile.createNewFile();

View Full Code Here
   1:     {
   2:       File output = new File(dirName, fileName);
   3: 
   4:         ...
   5:     {
   6:       System.out.println("Error writing the file " + e);
   7:     }
   8:   }
   9: }

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.FileOutputStream;
   4:         ...
   5: 
   6:     protected File gmlFile;
   7:     
   8:         ...
   9:             String path = resource.getFile();
  10:             File f=new File(path);
  11:             gmlFile = new File(f.getParent()+"/Streams.gml");
  12:         ...
  13:             gmlFile.createNewFile();

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.FileInputStream;
   4:         ...
   5:    
   6:    protected void store(MBeanInfo metadata, File location) throws IOException
   7:    {
   8:         ...
   9:        location.createNewFile();
  10:        FileOutputStream fos = new FileOutputStream(location);
  11:         ...
  12:    
  13:    protected MBeanInfo load(File location) 

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.IOException;
   4:         ...
   5:     public void testGetInputStreamFileFileString() throws IOException {
   6:         File f = new File(getTmpDir(), this.getName() + ".txt");
   7:         ...
   8:         f.createNewFile();
   9:         assertNotNull(f + " doesn't return inputstream",

View Full Code Here
   1:                 if ( Log.getStartStatus() == true ) {
   2:                     File f = new File( FileName );
   3:                     if ( f.exists() ) {
   4:         ...
   5:                     }
   6:                     f.createNewFile();
   7:                     Log.setStartStatus( false );
   8:                 }
   9:                 PrintWriter out = new PrintWriter( new FileOutputStream(

View Full Code Here
   1: import java.awt.event.*;
   2: import java.io.File;
   3: import java.io.IOException;
   4:         ...
   5:   private void initialize() {
   6:     File file = new File(dir, filename);
   7:     try {
   8:         ...
   9:       System.out.println("Creating temporary file");
  10:       file.createNewFile();
  11:     }

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.IOException;
   4:         ...
   5:     final String TEST_TYPE="testtype";
   6:     File f = new File( Config.TEST_LOCALROOT_FILE, "testdir" );
   7:     Assert.assertTrue("Can't create testdir",f.mkdir());
   8:         ...
   9:     f = new File( Config.TEST_LOCALROOT_FILE, "testdir/metatest.xml" );
  10:     f.createNewFile();
  11:     SyxawFile sf = new SyxawFile(f);

View Full Code Here
   1: import java.awt.event.*;
   2: import java.io.File;
   3: import java.io.IOException;
   4:         ...
   5:   private void initialize() {
   6:     File file = new File(dir, filename);
   7:     try {
   8:         ...
   9:       System.out.println("Creating temporary file");
  10:       file.createNewFile();
  11:     }

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.FileInputStream;
   4:         ...
   5: 
   6:     private final File          m_file;
   7:     private final Properties    m_properties;
   8:         ...
   9: 
  10:     AbstractPropertiesPersistor(Properties p, File f) {
  11:         assert (p != null);
  12:         ...
  13:         if (!m_file.exists()) {
  14:             m_file.createNewFile();

View Full Code Here
   1: import java.io.BufferedOutputStream;
   2: import java.io.File;
   3: import java.io.FileInputStream;
   4:         ...
   5:             throws IOException {
   6:         File file = new File(fileName);
   7: 
   8:         ...
   9:         File file = new File(fileName);
  10:         file.createNewFile();
  11:         writeEventContext(context, new FileOutputStream(file));

View Full Code Here
   1: 
   2: import java.io.File;
   3: import java.io.FileOutputStream;
   4:         ...
   5:     
   6:     CmdOutputToFile( File theFile )
   7:         throws java.io.IOException
   8:         ...
   9:     {
  10:         theFile.createNewFile( );
  11:         mOutput    = new PrintStream( new FileOutputStream( theFile, true ) );

View Full Code Here