Example usage for java.util UUID toString

List of usage examples for java.util UUID toString

Introduction

In this page you can find the example usage for java.util UUID toString.

Prototype

public String toString() 

Source Link

Document

Returns a String object representing this UUID .

Usage

From source file:Main.java

public static void main(String[] args) {
    // creating UUID      
    UUID uid = UUID.randomUUID();

    // checking string representation
    System.out.println("String value: " + uid.toString());
}

From source file:ProductionJS.java

/**
 * @param args/*from   w  w  w .  j ava 2  s.  co m*/
 */
public static void main(String[] args) {
    boolean precondition = true;
    BackupLog backupLog = new BackupLog("log/backupLog.txt");
    Property properties = null;
    Settings settings = null;

    // Load main cfg file
    try {
        properties = new Property("cfg/cfg");
    } catch (IOException e) {
        backupLog.log("ERROR : Config file not found");
        precondition = false;
    }

    // Load cfg for Log4J
    if (precondition) {
        try {
            DOMConfigurator.configureAndWatch(properties.getProperty("loggerConfiguration"));
            logger.info("ProductionJS is launched\n_______________________");
        } catch (Exception e) {
            backupLog.log(e.getMessage());
            precondition = false;
        }
    }

    // Load settings for current execution
    if (precondition) {
        try {
            settings = new Settings(new File(properties.getProperty("importConfiguration")));
        } catch (IOException e) {
            logger.error("Properties file not found");
            precondition = false;
        } catch (org.json.simple.parser.ParseException e) {
            logger.error("Properties file reading error : JSON may be invalid, check it!");
            precondition = false;
        }
    }

    // All is OK : GO!
    if (precondition) {
        logger.info("Configuration OK");
        logger.info("\"_______________________\nConcat BEGIN\n_______________________\n");

        Concat concat = new Concat();
        try {
            if (settings.getPrior() != null) {
                logger.info("Add Prior files\n_______________________\n");
                concat.addJSONArray(settings.getPrior());
            }

            for (int i = 0; i < settings.getIn().size(); i++) {
                ProductionJS.logger.info("Importation number " + (i + 1));
                ProductionJS.logger.info("Directory imported " + settings.getIn().get(i));

                Directory dir = new Directory(new File(settings.getIn().get(i).toString()));
                dir.scan();
                concat.add(dir.getFiles());
            }
            concat.output(settings.getOut());

            logger.info("\"_______________________\nConcat END\n_______________________\n");
            if (settings.getMinify() != null && settings.getMinify() == true) {
                logger.info(
                        "\"_______________________\nMinify of concatened file BEGIN\n_______________________\n");
                new Minify(new File(settings.getOut()), settings.getOut());
                logger.info(
                        "\"_______________________\nMinify of concatened file END\n_______________________\n");
            }

            if (settings.getLicense() != null) {
                logger.info("Add License\n_______________________\n");
                concat = new Concat();
                UUID uniqueID = UUID.randomUUID();

                PrintWriter tmp = new PrintWriter(uniqueID.toString() + ".txt");
                tmp.println(settings.getLicense());
                tmp.close();
                File license = new File(uniqueID.toString() + ".txt");
                concat.add(license);

                File out = new File(settings.getOut());
                File tmpOut = new File(uniqueID + out.getName());
                out.renameTo(tmpOut);
                concat.add(tmpOut);

                concat.output(settings.getOut());
                license.delete();
                tmpOut.delete();
            }
        } catch (IOException e) {
            StackTrace stackTrace = new StackTrace(e.getStackTrace());
            logger.error("An error occurred " + e.getMessage() + " " + stackTrace.toString());
        }
    }
}

From source file:Main.java

public static String parseUUID(UUID uuid) {
    String s = uuid.toString();
    if (s.matches(b)) {
        s = s.substring(4, 8);//from   w  w w  .  j a va 2 s  . c  o  m
    }
    return s;
}

From source file:Main.java

public static String stripDashes(UUID inputUuid) {
    String input = inputUuid.toString();
    return input.substring(0, 8) + input.substring(9, 13) + input.substring(14, 18) + input.substring(19, 23)
            + input.substring(24, 36);//from   ww w  .  j  a v  a  2  s.c o m
}

From source file:Main.java

public static String generateID() {
    UUID id = UUID.randomUUID();
    return id.toString();
}

From source file:Main.java

public static String getUUID() {
    UUID uuid = UUID.randomUUID();
    return uuid.toString();
}

From source file:Main.java

public synchronized static String orderNumGenerator() {
    UUID uuid = UUID.randomUUID();
    return uuid.toString();
}

From source file:Main.java

public static String getUUIDRandomString() {
    UUID uuid = UUID.randomUUID();
    return uuid.toString();
}

From source file:Main.java

public static String getUUID32() {
    UUID uuid = UUID.randomUUID();
    return uuid.toString().replaceAll("-", "");
}

From source file:Main.java

public static String getUniqueKey() {
    UUID uuid = UUID.randomUUID();
    return uuid.toString();
}