× 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.




I have not tried as a long, but I don't think it is possible to get long
values. I only know the methods
getFloatAttribute(int), getIntegerAttribute(int) and
getStringAttribute(int). Is there another way that you know of to
retrieve attribute values?



-----Original Message-----
From: java400-l-bounces@xxxxxxxxxxxx
[mailto:java400-l-bounces@xxxxxxxxxxxx] On Behalf Of Luis Colorado
Sent: woensdag 9 januari 2008 18:01
To: Java Programming on and around the iSeries / AS400
Subject: RE: Size of spooled file

Have you tried as a long?

-----Original Message-----
From: java400-l-bounces@xxxxxxxxxxxx
[mailto:java400-l-bounces@xxxxxxxxxxxx] On Behalf Of Steven Van Loon
Sent: Wednesday, January 09, 2008 6:14 AM
To: java400-l@xxxxxxxxxxxx
Subject: Size of spooled file

Hi,

Does anybody ever tried to retrieve the size of a SpooledFile via the
Toolkit? According to the documentation, a PrintObject attribute exists,
ATTR_NUMBYTES_SPLF, which should give back the size as an integer
(http://publib.boulder.ibm.com/iseries/v5r1/ic2924/info/rzahh/javadoc/Pr
intAttributes.html#HDRKEY174).

When I try to read it as an integer, I get an exception:
ExtendedIllegalArgumentException: ATTR_NUMBYTES_SPLF: Parameter value is
not valid.

When I try to read it as a string, I get an Exception:
ExtendedIllegalArgumentException: ATTR_NUMBYTES_SPLF: Parameter value is
not valid.

When I try to read it as a float, I get a value (!), but I don't know
how to interpret this value. I have the following piece of code to
execute:

public class SplfAttributes
{
public static void main(String[] args)
{
AS400 connection = new AS400(..., ..., ...);

String file = ...;
int number = ...;
String job = ...;
String jobuser = ...;
String jobnumber = ...;

SpooledFile splf = new SpooledFile(connection, file,
number, job, jobuser, jobnumber);

// Get value as int
int intValue;
try
{
intValue =
splf.getIntegerAttribute(PrintObject.ATTR_NUMBYTES_SPLF).intValue();
System.out.println("Int value = " + intValue);
}
catch (Exception ex)
{
System.out.println("Attribute is not an int");
}

// Get value as String
String stringValue;
try
{
stringValue =
splf.getStringAttribute(PrintObject.ATTR_NUMBYTES_SPLF);
System.out.println("String value = " +
stringValue);
}
catch (Exception ex)
{
System.out.println("Attribute is not a string");
}

// Get value as float
float floatValue;
try
{
floatValue =
splf.getFloatAttribute(PrintObject.ATTR_NUMBYTES_SPLF).floatValue();
System.out.println("float value = " +
floatValue);
}
catch (Exception ex)
{
System.out.println("Attribute is not a float");
}

try
{
// Calculate size by counting # bytes
int calculatedSize = 0;
PrintObjectInputStream str =
splf.getInputStream();
byte[] buffer = new byte[1024];
int bytes = str.read(buffer, 0, 1024);
while (bytes > 0)
{
calculatedSize += bytes;
bytes = str.read(buffer, 0, 1024);
}
System.out.println("Calculated size = " +
calculatedSize);
str.close();
}
catch (Exception ex)
{
System.out.println("Exception during
calculation:"+ex.getMessage());
ex.printStackTrace(System.out);
}
}
}


Executing the code produces the following output for some splf:

Attribute is not an int
Attribute is not a string
float value = 36.018665
Calculated size = 3602000

The size of the splf reported by 'WRKSPLFA FILE(...) JOB(.../.../...)
SPLNBR(...)' is 3656K.

How are these values related to each other? I see that 3602000 is
approximately 36.018665 times 10000 (10240 ?) but not exactly.

Anybody ideas how these values are calculated? Is there another way to
get the size of a spooled file? (calculating it like in the code above
is not an option).

Best regards,
Steven.




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.