- File fakeFile = new File(source.toURI()); // "story/index.html"
- fakeFile = new File(fakeFile.getParent()); // "story"
- fakeFile = new File(fakeFile, fakeFile.getName()); // "story/story"
- fakeSource = fakeFile.toURI().toURL();
- return new MarkableFileInputStream(new FileInputStream(fakeFile));
- } catch (URISyntaxException e) {
- throw new IOException(
- "file not supported (maybe not created with this program or corrupt)",
- e);
- } catch (MalformedURLException e) {
- throw new IOException("file not supported (bad URL)", e);
+ File fakeFile = new File(source.toURI());
+ if (fakeFile.getName().equals("index.html")) { // "story/index.html"
+ fakeFile = new File(fakeFile.getParent()); // -> "story/"
+ }
+
+ if (fakeFile.isDirectory()) { // "story/"
+ fakeFile = new File(fakeFile, fakeFile.getName() + ".txt"); // "story/story.txt"
+ }
+
+ if (fakeFile.getName().endsWith(".txt")) {
+ return fakeFile;
+ }
+ } catch (Exception e) {