[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.rcp] Re: How can I read or write the file in jar?

You might want to try something similar to the following:

private String getSchemaString() throws Exception
{
String schemaString = null;
try
{
JarFile jarFile = new JarFile (schemaJarFileName);
if (null == jarFile)
throw new Exception ("jarFile is null");


JarEntry schemaJarEntry = jarFile.getJarEntry("schema.ddl");
InputStream schemaInputStream = jarFile.getInputStream(schemaJarEntry);
int bytesAvailable = schemaInputStream.available();
char[] streamCharacterArray = new char [bytesAvailable];
InputStreamReader schemaInputReader = new InputStreamReader (schemaInputStream);
schemaInputReader.read(streamCharacterArray);

schemaString = new String (streamCharacterArray);
return schemaString;
}// try
catch (Exception e)
{
System.out.println ("ERROR: getSchemaString() : " + e.toString());
throw new Exception (e);
}// catch (Exception e)
}// private String getSchemaString() throws Exception


Hope this helps,

Charlie

Oh Sangin wrote:
My rcp package has the myRCP.jar in the plugin folder.
The myRCP.jar also has foo/property.xml file.
Then, how can I read or write the propety.xml.

Please, give me some code.
Thank you.