Modify groupId for ems driver
[vfc/nfvo/driver/ems.git] / ems / boco / src / main / java / org / onap / vfc / nfvo / emsdriver / commons / utils / StringUtil.java
1 /**
2  * Copyright 2017 BOCO Corporation.  CMCC Technologies Co., Ltd
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package org.onap.vfc.nfvo.emsdriver.commons.utils;
17
18 import java.io.File;
19 import java.io.PrintWriter;
20 import java.io.StringWriter;
21
22 public class StringUtil {
23
24         public static String getStackTrace(Throwable t){
25                 
26                 StringWriter sw = null;
27                 PrintWriter pw = null;
28                 try {
29                         sw = new StringWriter();
30                         pw = new PrintWriter(sw);
31                         t.printStackTrace(pw);
32                         pw.flush();
33                         sw.flush();
34                         return sw.getBuffer().toString();
35                 } catch (Exception e) {
36                         
37                 }finally{
38                         try {
39                                 if(pw != null) pw.close();
40                                 if(sw != null) sw.close();
41                         } catch (Exception e2) {
42                                 
43                         }
44                 }
45                 return null;
46         }
47
48         public static String addSlash(String dirName) {
49                 if (dirName.endsWith(File.separator))
50                         return dirName;
51                 return dirName + File.separator;
52         }
53         
54         public static  boolean isBank(String str){
55                 
56                 if(str == null || str.trim().length() == 0){
57                         
58                         return true;
59                 }
60                 return false;
61         }
62 }