diff --git a/epublib/src/main/java/me/ag2s/epublib/domain/FileResourceProvider.java b/epublib/src/main/java/me/ag2s/epublib/domain/FileResourceProvider.java index a9db2b5d9..e273712d6 100644 --- a/epublib/src/main/java/me/ag2s/epublib/domain/FileResourceProvider.java +++ b/epublib/src/main/java/me/ag2s/epublib/domain/FileResourceProvider.java @@ -16,21 +16,27 @@ public class FileResourceProvider implements LazyResourceProvider { /** * 创建一个文件夹里面文件夹的LazyResourceProvider,用于LazyResource。 - * @param dir 文件的目录 + * @param parentDir 文件的目录 */ - public FileResourceProvider(String dir) { - this.dir = dir; + public FileResourceProvider(String parentDir) { + this.dir = parentDir; } /** * 创建一个文件夹里面文件夹的LazyResourceProvider,用于LazyResource。 - * @param dirfile 文件夹 + * @param parentFile 文件夹 */ @SuppressWarnings("unused") - public FileResourceProvider(File dirfile) { - this.dir = dirfile.getPath(); + public FileResourceProvider(File parentFile) { + this.dir = parentFile.getPath(); } + /** + * 根据子文件名href,再父目录下读取文件获取FileInputStream + * @param href 子文件名href + * @return 对应href的FileInputStream + * @throws IOException 抛出IOException + */ @Override public InputStream getResourceStream(String href) throws IOException { return new FileInputStream(new File(dir, href)); diff --git a/epublib/src/main/java/me/ag2s/epublib/domain/TitledResourceReference.java b/epublib/src/main/java/me/ag2s/epublib/domain/TitledResourceReference.java index cba1ed83f..e7fe769ad 100644 --- a/epublib/src/main/java/me/ag2s/epublib/domain/TitledResourceReference.java +++ b/epublib/src/main/java/me/ag2s/epublib/domain/TitledResourceReference.java @@ -1,10 +1,10 @@ package me.ag2s.epublib.domain; +import java.io.Serializable; + import me.ag2s.epublib.Constants; import me.ag2s.epublib.util.StringUtil; -import java.io.Serializable; - public class TitledResourceReference extends ResourceReference implements Serializable { @@ -69,8 +69,11 @@ public class TitledResourceReference extends ResourceReference @Override public Resource getResource() { - //修复getTitle为null的bug - resource.setTitle(title); + //resource为null时不设置标题 + if(this.resource!=null&&this.title!=null){ + resource.setTitle(title); + } + return resource; }