]>
git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/CreateMdkPkg/src/org/tianocore/common/Tools.java
3 The file is used to provides some useful interfaces
5 Copyright (c) 2006, Intel Corporation
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 package org
.tianocore
.common
;
19 import java
.text
.SimpleDateFormat
;
20 import java
.util
.Date
;
21 import java
.util
.UUID
;
24 The class is used to provides some useful interfaces
26 @since CreateMdkPkg 1.0
37 public static void main(String
[] args
) {
38 System
.out
.println(getCurrentDateTime());
42 Get current date and time and format it as "yyyy-MM-dd HH:mm"
44 @return formatted current date and time
47 public static String
getCurrentDateTime() {
48 Date now
= new Date(System
.currentTimeMillis());
49 SimpleDateFormat sdf
= new SimpleDateFormat("yyyy-MM-dd HH:mm");
50 return sdf
.format(now
);
54 Delete a folder and all its files
56 @param fleFolderName The name of the folder which need be deleted
58 @retval true - Delete successfully
59 @retval false - Delete successfully
62 public static boolean deleteFolder(File fleFolderName
) {
63 boolean blnIsDeleted
= true;
64 File
[] aryAllFiles
= fleFolderName
.listFiles();
66 for (int indexI
= 0; indexI
< aryAllFiles
.length
; indexI
++) {
68 if (aryAllFiles
[indexI
].isDirectory()) {
70 //If is a directory, recursively call this function to delete sub folders
72 blnIsDeleted
= deleteFolder(aryAllFiles
[indexI
]);
73 } else if (aryAllFiles
[indexI
].isFile()) {
75 //If is a file, delete it
77 if (!aryAllFiles
[indexI
].delete()) {
84 fleFolderName
.delete();
92 @return the created UUID
95 public static String
generateUuidString() {
96 return UUID
.randomUUID().toString();
100 Get all system properties and output to the console
103 public static void getSystemProperties() {
104 System
.out
.println(System
.getProperty("java.class.version"));
105 System
.out
.println(System
.getProperty("java.class.path"));
106 System
.out
.println(System
.getProperty("java.ext.dirs"));
107 System
.out
.println(System
.getProperty("os.name"));
108 System
.out
.println(System
.getProperty("os.arch"));
109 System
.out
.println(System
.getProperty("os.version"));
110 System
.out
.println(System
.getProperty("file.separator"));
111 System
.out
.println(System
.getProperty("path.separator"));
112 System
.out
.println(System
.getProperty("line.separator"));
113 System
.out
.println(System
.getProperty("user.name"));
114 System
.out
.println(System
.getProperty("user.home"));
115 System
.out
.println(System
.getProperty("user.dir"));
116 System
.out
.println(System
.getProperty("PATH"));
118 System
.out
.println(System
.getenv("PROCESSOR_REVISION"));