1 /*******************************************************************************
2 * Copyright 2016-2017 ZTE, Inc. and others.
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 * in compliance with the License. You may obtain a copy of the License at
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software distributed under the License
10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 * or implied. See the License for the specific language governing permissions and limitations under
13 ******************************************************************************/
14 package org.onap.msb.apiroute.wrapper.util;
16 import java.io.BufferedReader;
18 import java.io.FileInputStream;
19 import java.io.FileNotFoundException;
20 import java.io.IOException;
21 import java.io.InputStreamReader;
23 public final class FileUtil {
26 * Read all the files under a folder
28 public static File[] readFileFolder(String filepath) throws FileNotFoundException, IOException {
29 File file = new File(filepath);
30 if (file.isDirectory()) {
31 File[] filelist = file.listFiles();
38 public static String readFile(String Path) throws IOException {
39 BufferedReader reader = null;
40 StringBuffer fileContent = new StringBuffer();
42 FileInputStream fileInputStream = new FileInputStream(Path);
43 InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8");
44 reader = new BufferedReader(inputStreamReader);
45 String tempString = null;
46 while ((tempString = reader.readLine()) != null) {
47 fileContent.append(tempString);
50 } catch (IOException e) {
56 } catch (IOException e) {
61 return fileContent.toString();
65 * Read all the files under a folder
67 public static String[] readfile(String filepath) throws FileNotFoundException, IOException {
68 File file = new File(filepath);
69 if (file.isDirectory()) {
70 String[] filelist = file.list();