1
I have a problem with Bytebuffer byteBuffer = Bytebuffer.NEW();
I can’t understand why I don’t have access to it. NEW, it simply doesn’t exist, I don’t think and I don’t find it... I need it to create the logic of a PDF to JPG conversion... Does anyone have an idea how to find it??? NOTE: It is for JAVA ANDROID.
byte[] bytes;
FileInputStream is = new FileInputStream(file);
long length = file.length();
bytes = new byte[(int) length];
int offset = 0;
int numRead = 0;
while (offset < bytes.length
&& (numRead = is.read(bytes, offset, bytes.length
- offset)) >= 0) {
offset += numRead;
}
ByteBuffer buffer = ByteBuffer.NEW(bytes);
String data = Base64.encodeToString(bytes, Base64.DEFAULT);
PDFFile pdf_file = new PDFFile(buffer);
PDFPage page = pdf_file.getPage(1);
I found this example on Google, but I can’t remember where (I lost the link)...
I can find no method
NEW
in documentation, in fact it is strange a method with capitalized name (in Java, usually only use everything in upper case to denote constants). Where do you know this method from, do you have any reference you can indicate? Anyway, see if the methodallocate
orallocateDirect
don’t suit you, or maybe thewrap
if you already have an array of bytes and want to create a buffer from it.– mgibsonbr
Hello friend! I edited my question with the code I doubt, it is to take a page from a PDF and convert to JPG
– Vinithius
In that case, most likely what you want is the
wrap
. Maybe theNEW
refers to some fairly old version of the API, I don’t know... Try:ByteBuffer buffer = ByteBuffer.wrap(bytes);
– mgibsonbr
Okay, I’ll take the test and pass the feedback!
– Vinithius