Код: Выделить всё
public class PdfByteReader {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
String filePath = args[0];
try {
String pdfContent = readPdfFileByteByByte(filePath);
System.out.println(pdfContent);
} catch (IOException e) {
System.err.println("ERROR" + e.getMessage());
}
}
public static String readPdfFileByteByByte(String filePath) throws IOException {
File pdfFile = new File(filePath);
StringBuilder content = new StringBuilder();
try (FileInputStream fis = new FileInputStream(pdfFile)) {
int byteRead;
while ((byteRead = fis.read()) != -1) {
content.append((char) byteRead);
}
}
return content.toString();
}
}
Я пытаюсь проанализировать файл PDF в строку, чтобы загрузить его в API>
Подробнее здесь: https://stackoverflow.com/questions/784 ... otusscript