cancel
Showing results for 
Search instead for 
Did you mean: 

get byte[] from Resource

Former Member
0 Kudos

Hi,all

I want to get byte[] from Resource property that I'm using in FileUpload element.

How can I do it?

Regards,

Michael

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

solved by myself

Former Member
0 Kudos

hi,

u can use this code for getting data

IPrivateExtractData.IContextElement contextElement = wdContext.currentContextElement();

byte[] bytes = contextElement.getPdfSource();

try

{

File file = new File("C:
Trilochan
generate.pdf");

FileOutputStream os = new FileOutputStream(file);

os.write(bytes);

os.close();

}

catch (IOException e)

{

e.printStackTrace();

}

hope this will work for u.

Regards

Trilochan

Former Member
0 Kudos

ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(wdContext.currentContextElement().getFileResource());

InputStreamReader isr = new InputStreamReader(byteArrayInputStream);

BufferedReader br = new BufferedReader(isr);

wdThis.wdGetMesarimAppController().fillTables();

String line = "";

try {

int i = 0;

while ((line = br.readLine())!=null && i<10) {

String l = line;

}

}catch (Exception e){

e.printStackTrace();

}

Edited by: Yoel Malekan on Apr 10, 2008 11:24 AM

Former Member
0 Kudos

Hi,

you can give a try with the following code



  IWDResource r; // Your existing resource
	  byte b[];
	  InputStream inputStream;
	try {
		inputStream = r.read(true);
		
		  int x = inputStream.read(b);
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}

Regards

Ayyapparaj