Package java.io

Examples of java.io.File.createNewFile()


  }

  public static boolean writeFile(String fileName, String text, boolean isAppend) {
    File file = new File(fileName);
    try {
      file.createNewFile();
      FileOutputStream fos = new FileOutputStream(file, isAppend);
      fos.write(text.getBytes("GBK"));
      fos.flush();
      fos.close();
      return true;
View Full Code Here


        File templateFile = new File(confDirectory, CONF_DIRECTORY + getFileSeparator() + TEMPLATE_FILE);
        String readFile = readFile(templateFile);

        File tempDirectory = ContextHolder.getContext().getTempDirectory();
        File configurationFile = new File(tempDirectory, CONF_FILE);
        if (!configurationFile.exists() && !configurationFile.createNewFile()) {
            log.error("Failed to create file " + CONF_FILE + ".");
        } else {
            String replacement = getReplacement(readFile, alternativeValues);
            writeFile(configurationFile, replacement);
        }
View Full Code Here

            String fileName) throws IOException {
        if (fileName == null) {
            fileName = toCopy.getName();
        }
        File copy = new File(destinationDir, fileName);
        Assert.assertTrue(copy.createNewFile());
        FileInputStream fis = new FileInputStream(toCopy);
        FileOutputStream fos = new FileOutputStream(copy);
        byte[] buffer = new byte[8192];
        int read = 0;
        while ((read = fis.read(buffer)) > 0) {
View Full Code Here

                                    File nextInFile = lof[i];
                                    if (nextInFile.isDirectory()) {
                                      continue;
                                    }
                                    File outFile = new File(resultImagesDir, nextInFile.getName());
                                    outFile.createNewFile();
                                    FileInputStream inStream = new FileInputStream(nextInFile);
                                    FileOutputStream outStream = new FileOutputStream(outFile);
                                    byte[] buffer = new byte[(int) nextInFile.length()];
                                    inStream.read(buffer);
                                    outStream.write(buffer);
View Full Code Here

       
    }
    private static File replaceExtension(File f, String newExtension) throws IOException {
        File result = FileUtil.replaceExtension(f, newExtension);
        if (!result.exists()) {
            result.createNewFile();
        }
        return result;
    }
   
    private static File appendSuffixBeforeExtension(File f, String suffix) throws IOException {
View Full Code Here

        final Set<String> fileNames = blFile.getFileNamesUnified();
        for (final String fileName : fileNames) {
            // make sure all requested blacklist files exist
            final File file = new File(this.blacklistRootPath, fileName);
            try {
                file.createNewFile();
            } catch (final IOException e) { /* */ }

            // join all blacklists from files into one internal blacklist map
            loadedBlacklist = SetTools.loadMapMultiValsPerKey(file.toString(), sep).entrySet();
            for (final Iterator<Map.Entry<String, List<String>>> mi = loadedBlacklist.iterator(); mi.hasNext();) {
View Full Code Here

                if (ddlFile.getParentFile() != null && !ddlFile.getParentFile().exists())
                {
                    // Make sure the directory exists
                    ddlFile.getParentFile().mkdirs();
                }
                ddlFile.createNewFile();
                ddlFileWriter = new FileWriter(ddlFile);

                SimpleDateFormat fmt = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
                ddlFileWriter.write("------------------------------------------------------------------\n");
                ddlFileWriter.write("-- JPOX SchemaTool " +
View Full Code Here

    }

   
    public IFileInfo newFile(String id, String mimeType, int cacheExpireTime) throws IOException {
      File file = new File(fileBasepath + File.separator + id + "." + encode(mimeType) + "." + encode(Integer.toString(cacheExpireTime)));
      file.createNewFile();

      return new FileInfo(file, mimeType, id, file.lastModified(), cacheExpireTime);
    }

   
View Full Code Here

            f = new File(dataHome, "DATA/yacy.running");
            if (f.exists()) {                // another instance running? VM crash? User will have to care about this
                Log.logSevere("STARTUP", "WARNING: the file " + f + " exists, this usually means that a YaCy instance is still running");
                delete(f);
            }
            if(!f.createNewFile())
                Log.logSevere("STARTUP", "WARNING: the file " + f + " can not be created!");
            try { new FileOutputStream(f).write(Integer.toString(OS.getPID()).getBytes()); } catch (final Exception e) { } // write PID
            f.deleteOnExit();

            final String oldconf = "DATA/SETTINGS/httpProxy.conf".replace("/", File.separator);
View Full Code Here

    if(!file.exists())
      file.mkdir();
    file = new File(fileMessage);
    if(!file.exists())
      try {
        file.createNewFile();
        //System.out.println(" **************************************************** Good create file  : "+f);
      } catch (IOException e) {
        e.printStackTrace();
      }
        factory = DocumentBuilderFactory.newInstance();
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.