use of org.apache.pdfbox.io.RandomAccessFile in project Gargoyle by callakrsos.
the class MD4CheckSum method main.
/**
* @작성자 : KYJ
* @작성일 : 2017. 5. 22.
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
File file = new File("C:\\Users\\KYJ\\Music\\뜸부기\\다모뮤직(damo.kr) 멜론(Melon) 5월 1일 실시간 Top100", "015 볼빨간사춘기 - 좋다고 말해.mp3");
RandomAccessFile accessFile = new RandomAccessFile(file, "r");
byte[] b = new byte[3];
if (accessFile.available() >= 3 && (accessFile.read(b) != -1) && "ID3".equals(new String(b))) {
accessFile.seek(3);
b = new byte[4];
accessFile.read(b, 0, 4);
int id3Size = b[0] << 21 | b[1] << 14 | b[2] << 7 | b[3];
System.out.println(id3Size);
accessFile.seek(id3Size + 10);
} else {
accessFile.seek(0);
}
for (int i = 0; i < 500000; i++) {
int a = accessFile.read();
if (a == 255) {
a = accessFile.read();
if ((a >> 5) == 7) {
accessFile.seek(accessFile.getPosition() - 2);
}
}
}
b = new byte[163840];
accessFile.read(b, 0, 163840);
accessFile.close();
System.out.println(testMD5(b));
System.out.println("e27b9cde01eac6e77caba1ba599f67d7");
}
use of org.apache.pdfbox.io.RandomAccessFile in project tutorials by eugenp.
the class PDF2TextExample method generateTxtFromPDF.
private static void generateTxtFromPDF(String filename) throws IOException {
File f = new File(filename);
String parsedText;
PDFParser parser = new PDFParser(new RandomAccessFile(f, "r"));
parser.parse();
COSDocument cosDoc = parser.getDocument();
PDFTextStripper pdfStripper = new PDFTextStripper();
PDDocument pdDoc = new PDDocument(cosDoc);
parsedText = pdfStripper.getText(pdDoc);
if (cosDoc != null)
cosDoc.close();
if (pdDoc != null)
pdDoc.close();
PrintWriter pw = new PrintWriter("src/output/pdf.txt");
pw.print(parsedText);
pw.close();
}
Aggregations