2 * Copyright 2016 ZTE, Inc. and others.
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.
17 package org.onap.msb.apiroute.wrapper.util;
19 import java.io.BufferedReader;
21 import java.io.FileInputStream;
22 import java.io.FileNotFoundException;
23 import java.io.IOException;
24 import java.io.InputStreamReader;
26 public final class FileUtil {
29 * Read all the files under a folder
31 public static File[] readFileFolder(String filepath) throws FileNotFoundException, IOException {
32 File file = new File(filepath);
33 if (file.isDirectory()) {
34 File[] filelist = file.listFiles();
41 public static String readFile(String Path) throws IOException{
42 BufferedReader reader = null;
43 StringBuffer fileContent = new StringBuffer();
45 FileInputStream fileInputStream = new FileInputStream(Path);
46 InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8");
47 reader = new BufferedReader(inputStreamReader);
48 String tempString = null;
49 while ((tempString = reader.readLine()) != null) {
50 fileContent.append(tempString);
53 } catch (IOException e) {
59 } catch (IOException e) {
64 return fileContent.toString();
68 * Read all the files under a folder
70 public static String[] readfile(String filepath) throws FileNotFoundException, IOException {
71 File file = new File(filepath);
72 if (file.isDirectory()) {
73 String[] filelist = file.list();