2 * Copyright 2016 2015-2016 ZTE, Inc. and others. All rights reserved.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package org.openo.msb.wrapper.util;
18 import java.io.BufferedReader;
20 import java.io.FileInputStream;
21 import java.io.FileNotFoundException;
22 import java.io.IOException;
23 import java.io.InputStreamReader;
25 public final class FileUtil {
28 * Read all the files under a folder
30 public static File[] readFileFolder(String filepath) throws FileNotFoundException, IOException {
31 File file = new File(filepath);
32 if (file.isDirectory()) {
33 File[] filelist = file.listFiles();
40 public static String readFile(String Path) throws IOException{
41 BufferedReader reader = null;
42 String fileContent = "";
44 FileInputStream fileInputStream = new FileInputStream(Path);
45 InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8");
46 reader = new BufferedReader(inputStreamReader);
47 String tempString = null;
48 while ((tempString = reader.readLine()) != null) {
49 fileContent += tempString;
52 } catch (IOException e) {
58 } catch (IOException e) {