× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



In debugging the application further I came across this oddity: I added the following to the downloadFile method:

(actually, I uncommented it)

int bytesread = source.read(buffer); // see how many bytes are read

and the spreadsheet started to open correctly again. I have no idea why. The buffer isn't altered, just read.

Whatever the source.read(buffer) does, it fixes the problem so I am going to go with it.

I am sure there is a rational explanation but I don't have time to get to the bottom of it.

Pete


Pete Helgren wrote:
I have been hunting around the Net for a solution and I have wondered if translation was an issue. I don't specifically translate anything I know of. Once the spreadsheet is created the getSpreadSheet method does the following:

public byte[] getSpreadSheet(String sheetname, UserContainer userContainer) throws IOException{
String userId = userContainer.getDaoContainer().getUserId();
String filePath = _spreadsheetPath + userId.trim();
byte[] outFile = null;
// We'll need some logic to use either the AS400 routines or the
// regular file utility
if(_i5os) // properties value
outFile = AS400FileUtility.downloadFile(userContainer.getDaoContainer(), filePath, sheetname);
else
outFile = FileUtility.downloadFile(filePath, sheetname);

return ourFile;
}

I originally thought the issue was here because the downloadFile method would use the AS400FileUtility class and it could account for the difference I was seeing when things ran on the System i vs on my notebook, but after the new war deployed to Tomcat (5.0.28) , both the System i and my local notebook produce a bad excel file.

FWIW the downloadFile method is:

public static byte[] downloadFile(String filepath, String filename) throws IOException {
FileInputStream source = null;
try {
String sourceName = filepath + File.separator + filename;
// Path and file should have been created by spreadsheet builder
// which puts the file into the folder. We are just retrieving it here

source = new FileInputStream(sourceName);
int available = source.available();
System.out.println("Source file successfully opened");

byte[] buffer = new byte[available];

//int bytesread = source.read(buffer);
//System.out.println("Bytes read:" + bytesread);

return buffer;

} catch (IOException e) {
e.printStackTrace();
return null;
} finally {
if (source != null)
source.close();

}
}

Not being a "raw" file reader, how would I go about "comparing the hex values"?

Thanks

Pete


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.