1 | |
package org.jbehave.core.io; |
2 | |
|
3 | |
import java.io.IOException; |
4 | |
import java.io.InputStream; |
5 | |
import java.net.URL; |
6 | |
|
7 | |
import org.apache.commons.io.IOUtils; |
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | 2 | public class LoadFromURL implements ResourceLoader, StoryLoader { |
13 | |
|
14 | |
public String loadResourceAsText(String resourcePath) { |
15 | |
try { |
16 | 2 | return IOUtils.toString(resourceAsStream(resourcePath)); |
17 | 1 | } catch (Exception cause) { |
18 | 1 | throw new InvalidStoryResource(resourcePath, cause); |
19 | |
} |
20 | |
} |
21 | |
|
22 | |
public String loadStoryAsText(String storyPath) { |
23 | 2 | return loadResourceAsText(storyPath); |
24 | |
} |
25 | |
|
26 | |
protected InputStream resourceAsStream(String resourcePath) throws IOException { |
27 | 2 | return new URL(resourcePath).openStream(); |
28 | |
} |
29 | |
|
30 | |
} |