大家好,我想创建一个 pdf 阅读器,它将读取硬编码的 pdf 并在控制台中打印数据。我使用了以下代码..
public class pdfreader {
public static void main(String args[]) throws Exception {
readResourceFileAndPrintContents();
}
private static void readResourceFileAndPrintContents() throws Exception {
InputStream stream = loadResourceAsStream("/home/ajay/Downloads/Beginning iPhone Development.pdf");
BufferedReader in = new BufferedReader(new InputStreamReader(stream));
String line;
while ((line = in.readLine()) != null) {
System.out.println((line));
}
}
public static InputStream loadResourceAsStream(final String resourceName) {
InputStream input = null;
try {
input = new FileInputStream(resourceName);
} catch (FileNotFoundException e) {
System.out.println("Resource File Not Found");
e.printStackTrace();
}
return input;
}
}
但我没有得到上下文。你能帮帮我吗..谢谢。