2 * Copyright (C) 2016 ZTE, Inc. and others. All rights reserved. (ZTE)
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
17 package org.openo.msb.wrapper.util;
\r
19 import java.io.BufferedReader;
\r
20 import java.io.File;
\r
21 import java.io.FileInputStream;
\r
22 import java.io.FileNotFoundException;
\r
23 import java.io.IOException;
\r
24 import java.io.InputStreamReader;
\r
26 public final class FileUtil {
\r
29 * Read all the files under a folder
\r
31 public static File[] readFileFolder(String filepath) throws FileNotFoundException, IOException {
\r
32 File file = new File(filepath);
\r
33 if (file.isDirectory()) {
\r
34 File[] filelist = file.listFiles();
\r
41 public static String readFile(String Path) throws IOException{
\r
42 BufferedReader reader = null;
\r
43 String fileContent = "";
\r
45 FileInputStream fileInputStream = new FileInputStream(Path);
\r
46 InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8");
\r
47 reader = new BufferedReader(inputStreamReader);
\r
48 String tempString = null;
\r
49 while ((tempString = reader.readLine()) != null) {
\r
50 fileContent += tempString;
\r
53 } catch (IOException e) {
\r
56 if (reader != null) {
\r
59 } catch (IOException e) {
\r