Java Build file

Source: Internet
Author: User

Java Build file


1. Description

takes a file path as a parameter, infers whether the file exists, and creates the file if it does not exist. and output file path


2. Implement source code

/** * @Title: Buildfile.java * @Package: Com.you.freemarker.model * @Description: Generate file * @author: Youhaidong (Zhanghaidong) * @date : 2014-6-30 PM 10:28:42 * @version V1.0 */package com.you.freemarker.model;import java.io.file;/** * Class Function Description * Class Change date * Change said Ming * <p>Title:BuildFile.java</p> * <p>description: Zhanghaidong personal Development </p> * <p>copyright:copyright ( c) 2013</p> * @author: Zhanghaidong * @date: 2014-6-30 pm 10:28:42 * @version V1.0 */public class BuildFile {/** * infer if the file exists.  Create file if not present * @Title: BuildFile * @Description: * @param: @param path * @param: @return * @return: String * @throws */Public    static string BuildFile (string path) {//Gets the file path as well as the file name, FileName: ' New file ' (path); If the file does not exist if (!file.exists ()) {try {//Create file File.createnewfile ();} catch (Exception e) {e.printstacktrace ()}}    return path;  }/** * @Title: Main * @Description: * @param: @param args * @return: void * @throws */public static void Main (string[] args) {//file path created by string path = "d:\\myeclipse\\workspace\\file.ftL ";//Call file generation method String FilePath = buildfile (path); Print the path to the generated file System.out.println ("Generated file path:" +filepath);}}

3. Achieve Results

(1) Console print results

Generated file path: D:\MYECLIPSE\WORKSPACE\FILE.FTL


(2) Generated files


Java Build file

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.