当我尝试从pdf和doc等驱动器文件中读取文本时,文本格式将按以下方式进行。
%PDF-1.3
%âãÏÓ
7 0 obj
<</Linearized 1/L 7945/O 9/E 3524/N 1/T 7656/H [ 451 137]>>
endobj
13 0 obj
<</DecodeParms<</Columns 4/Predictor 12>>/Filter/FlateDecode/ID[<4DC91A1875A6D707AEC203BB021C93A0><F6C92B368A8A13408457A1D395A37EB9>]/Index[7 21]/Info 6 0 R/Length 52/Prev 7657/Root 8 0 R/Size 28/Type/XRef/W[1 2 1]>>stream
hÞbbd``b`² ±H0§ 6G ñå#Ã4,#¹ÄÆ_L¤ð
endstream
endobj
startxref
0
%%EOF
27 0 obj
<</Filter/FlateDecode/I 69/Length 58/S 38>>stream
hÞb```a``üÏÜ6¨¬$ËѬ,ÆÅ
ÜÜÓt&¬8ÌZ-R,¿â
endstream
endobj
8 0 obj
<</Metadata 1 0 R/Pages 5 0 R/Type/Catalog>>
endobj
9 0 obj
<</Contents 11 0 R/CropBox[0 0 595 842]/MediaBox[0 0 595 842]/Parent 5 0 R/Resources 14 0 R/Rotate 0/Type/Page>>
endobj
请找到以下代码:
DriveContents contents = result.getDriveContents();
BufferedReader reader = new BufferedReader(new InputStreamReader(contents.getInputStream()));
StringBuilder builder = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
builder.append(line);
}
String contentsAsString = builder.toString();
但实际上,我需要原始格式的文字here
请帮帮我。