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