Hi all! I'm not sure whether this question/prob have been posed or not but
here we go. I need to know how to read a class in a jar file and store in
jackrabbit. Am I in the right forum? I hope I am lol. Below is the snippet
of coding I use to read the jar file content... This code works and it
captured the content of the jar file but when I tried to download it from
the repository the .class file is corrupted. But if there's a .txt file in
the jar file... it will read it correctly and download without a problem.
Please help me with this, thanks. My question is how to read the jar file
and save it in an InputStream.
public InputStream getInputStream() throws IOException {
InputStream stream = null;
//String jarFilename = "brmsPackage\\test.jar";
String jarFilename = "C:/MyFolder/Customer.jar";
byte[] l_bFileContent=null;
try {
StringBuffer result = new StringBuffer();
FileInputStream inputStream = new
FileInputStream(jarFilename);
int read = 0;
do {
read = inputStream.read();
System.out.println("huh "+read);
result.append((char)read);
System.out.println("huh 2 "+result);
} while (read != -1);
String l_sFileContent=result.toString();
System.out.println("huh 3 "+l_sFileContent);
l_bFileContent=l_sFileContent.getBytes();
}
catch (IOException e) { System.out.println (e); }
stream = new ByteArrayInputStream(l_bFileContent);
return stream;
}
--
View this message in context:
http://www.nabble.com/Reading-contents-of-JAR-FILE-and-save-to-Repository-tp20086183p20086183.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.