--- /dev/null
+/**\r
+* Copyright (C) 2016 ZTE, Inc. and others. All rights reserved. (ZTE)\r
+*\r
+* Licensed under the Apache License, Version 2.0 (the "License");\r
+* you may not use this file except in compliance with the License.\r
+* You may obtain a copy of the License at\r
+*\r
+* http://www.apache.org/licenses/LICENSE-2.0\r
+*\r
+* Unless required by applicable law or agreed to in writing, software\r
+* distributed under the License is distributed on an "AS IS" BASIS,\r
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* See the License for the specific language governing permissions and\r
+* limitations under the License.\r
+*/\r
+\r
+package org.openo.msb.wrapper.util;\r
+\r
+import java.io.BufferedReader;\r
+import java.io.File;\r
+import java.io.FileInputStream;\r
+import java.io.FileNotFoundException;\r
+import java.io.IOException;\r
+import java.io.InputStreamReader;\r
+\r
+public final class FileUtil {\r
+\r
+ /**\r
+ * Read all the files under a folder\r
+ */\r
+ public static File[] readFileFolder(String filepath) throws FileNotFoundException, IOException {\r
+ File file = new File(filepath);\r
+ if (file.isDirectory()) {\r
+ File[] filelist = file.listFiles();\r
+ return filelist;\r
+ }\r
+ \r
+ return null;\r
+ }\r
+\r
+ public static String readFile(String Path) throws IOException{\r
+ BufferedReader reader = null;\r
+ String fileContent = "";\r
+ try {\r
+ FileInputStream fileInputStream = new FileInputStream(Path);\r
+ InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8");\r
+ reader = new BufferedReader(inputStreamReader);\r
+ String tempString = null;\r
+ while ((tempString = reader.readLine()) != null) {\r
+ fileContent += tempString;\r
+ }\r
+ reader.close();\r
+ } catch (IOException e) {\r
+ throw e;\r
+ } finally {\r
+ if (reader != null) {\r
+ try {\r
+ reader.close();\r
+ } catch (IOException e) {\r
+ throw e;\r
+ }\r
+ }\r
+ }\r
+ return fileContent;\r
+ }\r
+}\r