2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.controller.config.yang.test.plugin;
11 import java.io.BufferedReader;
13 import java.io.FileInputStream;
14 import java.io.IOException;
15 import java.io.InputStream;
16 import java.io.InputStreamReader;
17 import java.util.regex.Matcher;
21 public static String replaceDots(String path) {
22 path = path.replace(".", Matcher.quoteReplacement(File.separator));
26 public static String loadHeader() throws IOException {
27 StringBuffer header = new StringBuffer();
28 InputStream headIn = Util.class.getClassLoader().getResourceAsStream("Header.txt");
29 BufferedReader headBuf = new BufferedReader(new InputStreamReader(headIn));
31 while ((line = headBuf.readLine()) != null) {
32 header.append(line).append(System.lineSeparator());
35 return header.toString();
38 public static String loadStubFile(String fileName) throws IOException {
39 InputStream stubIn = new FileInputStream(fileName);
40 BufferedReader stubBuf = new BufferedReader(new InputStreamReader(stubIn));
42 StringBuffer stubLines = new StringBuffer();
43 String stubLine = null;
44 while ((stubLine = stubBuf.readLine()) != null) {
45 stubLines.append(stubLine).append(System.lineSeparator());
48 return stubLines.toString();