Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possibility to read MEMO field as binary data, regardless of field defintion #98

Closed
HelmutL opened this issue Sep 29, 2021 · 3 comments
Closed
Assignees
Milestone

Comments

@HelmutL
Copy link

HelmutL commented Sep 29, 2021

I have a file in an application that has been written using Visual Foxpro.
The file contains MEMO type fields. The byte 18 of the field definition is 0x00, The byte 3 in the Memo Block Header (in the memofile) is set to 0x01 (text).

Nevertheless, this field contains images (e.g. JPG type) and it seems Visual Foxpro does not care.

Now, reading these fields by DBFReader converts them to String, which makes the data unusable, even if converted to byte[] by String.getBytes();

I need a possiblity to bypass this conversion and read the field's "raw data" to a byte[].

Regards

@albfernandez albfernandez self-assigned this Oct 2, 2021
@albfernandez albfernandez added this to the 2.0 milestone Jan 4, 2024
@albfernandez
Copy link
Owner

Hi

A new method will be available in 2.0 to override default, and force to read memo fieds as binary

setReadMemoFieldAsBinary
You must call this method before read the data

Example:

File file = new File("src/test/resources/fixtures/dbase_8b.dbf");
DBFReader reader  = null;
try {
	reader = new DBFReader( new BufferedInputStream(new FileInputStream(file)));
	reader.setMemoFile(new File("src/test/resources/fixtures/dbase_8b.dbt"));
	reader.setReadMemoFieldsAsBinary("MEMO");
	DBFRow row = null;
	while ((row = reader.nextRow()) != null) {
		byte[] data = row.getBytes("MEMO");
		// Do whatever you wan't with de data
	}
			
}
finally {
	DBFUtils.close(reader);
}

@HelmutL
Copy link
Author

HelmutL commented Feb 26, 2024 via email

@albfernandez
Copy link
Owner

Hi @HelmutL

The files are missed. Maybe you can upload the files on the issue related to write memo files #40

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants