on 08-31-2009 3:05 PM
Hy guys!
Please, help me!
Where is the problem or error in this code:
IWDResource fileUploadUI;
InputStream fileStream;
byte[] byteArray = null;
for (int n = 0; n < wdContext.nodeFileUploadNode().size(); n++) {
fileUploadUI = wdContext.nodeFileUploadNode().getFileUploadNodeElementAt(n).getFileUploadAttr();
try {
fileStream = fileUploadUI.read(false);
*int noOfBytes = fileStream.available();* ERROR
byteArray = new byte[noOfBytes];
*int byteRead = fileStream.read(byteArray, 0, noOfBytes);* ERROR
} catch (IOException e) {
e.printStackTrace();
}
wdContext.currentCreateAttachRFCElement().setMessage_Key(wdContext.currentContextElement().getServiceRequestID());
wdContext.currentCreateAttachRFCElement().setAtt_Name(fileUploadUI.getResourceName());
wdContext.currentCreateAttachRFCElement().setAtt_Bin(byteArray);
executeCreateAttachRFC();
}
Thanks!
Kleber
Hi Kleber,
Please check this [javadoc|http://java.sun.com/j2se/1.4.2/docs/api/java/io/InputStream.html#available()]. It will explain why you get an error.
Hope this helps.
regards,
Alain
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi guys,
It works fine:
IWDResource fileUploadUI;
InputStream fileStream;
byte[] byteArray = null;
byte[] byteArrayOrig = null;
for (int n = 0; n < wdContext.nodeFileUploadNode().size(); n++) {
fileUploadUI = wdContext.nodeFileUploadNode().getFileUploadNodeElementAt(n).getFileUploadAttr();
try {
if (n < wdContext.nodeAtts().size()) {
byteArrayOrig = wdContext.nodeAtts().getAttsElementAt(n).getAtt_Bin();
}
fileStream = fileUploadUI.read(false);
byteArray = new byte[fileStream.available()];
int byteRead = fileStream.read(byteArray, 0, fileStream.available());
if (Arrays.equals(byteArrayOrig,byteArray)) {
continue;
}
} catch (IOException e) {
e.printStackTrace();
}
wdContext.currentCreateAttachRFCElement().setMessage_Key(wdContext.currentContextElement().getServiceRequestID());
wdContext.currentCreateAttachRFCElement().setAtt_Name(fileUploadUI.getResourceName());
wdContext.currentCreateAttachRFCElement().setAtt_Bin(byteArray);
executeCreateAttachRFC();
}
Thanks!
Kleber
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
copy&paste your Stack Trace or compilation errors
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.