cancel
Showing results for 
Search instead for 
Did you mean: 

Again: UDF: Load file from "imported archives"

Former Member
0 Kudos

Hi everybody,

I tried to read a txt-File from the "imported archives".

The following does not work:

try {

+ FileInputStream fstream = new FileInputStream(Filename);+

+ DataInputStream in = new DataInputStream(fstream);+

+ BufferedReader br = new BufferedReader(new InputStreamReader(in));+

} catch (Exception e) {// Catch exception if any

+ return "Error: " + e.getMessage();+

}//catch

return "test";

I get the error:

abc.txt (No such file or directory)

Any ideas?

regards Mario

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Thanks a lot.

Regards Mario

Former Member
0 Kudos

not at all,

give points if was helpfull.

regards.

roberti

Former Member
0 Kudos

Sorry waldemar,

was not helpful, but nice to talk to you.

Regards Mario

Former Member
0 Kudos

How have you done?

roberti

Former Member
0 Kudos

InputStream fstream = this.getClass().getClassLoader().getResourceAsStream(fileName);

Regards Mario

Former Member
0 Kudos

Ok, but you said you need the lines, how did you get it?

Former Member
0 Kudos

Hi Mario,

I think it will not be possible. Think those objects in integration repository are stored on database tables (I'm not sure about it). If you have access to the operating system console where you have your XI installed, try to find from the root directory for all occurrences for the "abc.txt" file. If it is not stored on database will be stored in some folder on file system and you can open it with its relative path.

regards.

roberti

Former Member
0 Kudos

Hi roberti,

it is possible!

I found some coding that works:

String returnString="";

byte[] buffer;

try {

InputStream is = this.getClass().getClassLoader().getResourceAsStream(filename);

buffer = new byte [is.available()];

is.read (buffer);

returnString = new String (buffer, "ISO-8859-1");

}

catch (Exception e) {

returnString = e.getMessage();

}

return returnString;

Unfortunately this coding gets the whole file in once. But I need the single lines.

Thats why I tried to use FileInputStream instead on InputStream

Any idea?

Regards Mario

Former Member
0 Kudos

Ok,

You can try searching for the end of line char, and split the lines from the result string from it in an string array. Otherwise, if you want to read the file try searching for the file as I said...

regards.

roberti