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 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 StringBuilder fileContent = new StringBuilder();
40 try(BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(Path),"UTF-8"));) {
41 String tempString = null;
42 while ((tempString = reader.readLine()) != null) {
43 fileContent.append(tempString);
45 } catch (IOException e) {
48 return fileContent.toString();
52 * Read all the files under a folder
54 public static String[] readfile(String filepath) throws FileNotFoundException, IOException {
55 File file = new File(filepath);
56 if (file.isDirectory()) {
57 String[] filelist = file.list();