java PDF文件解析成String的代码

658 阅读1分钟
下边资料是关于java PDF文件解析成String的内容。

try {
	document = PDDocument.load(file);
	ByteArrayOutputStream baos = new ByteArrayOutputStream();
	output = new OutputStreamWriter(baos);
	stripper = new PDFTextStripper();
	stripper.writeText(document, output);
	return baos.toString();
} catch (MalformedURLException e) {
	throw e;
} finally {
		output.close();
	}
		document.close();
	}
}