public byte[] createJarFromFileContent(final String fileName,final String content) throws IOException {
  ByteArrayOutputStream byteArrayOutputStream=new ByteArrayOutputStream();
  JarOutputStream jarOutputStream=new JarOutputStream(byteArrayOutputStream);
  JarEntry entry=new JarEntry(fileName);
  entry.setTime(System.currentTimeMillis());
  jarOutputStream.putNextEntry(entry);
  jarOutputStream.write(content.getBytes());
  jarOutputStream.closeEntry();
  jarOutputStream.close();
  return byteArrayOutputStream.toByteArray();
}

public byte [ ] createJarFromFileContent ( final String fileName , final String content ) throws IOException { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream ( ) ; JarOutputStream jarOutputStream = new JarOutputStream ( byteArrayOutputStream ) ; JarEntry entry = new JarEntry ( fileName ) ; entry . setTime ( System . currentTimeMillis ( ) ) ; jarOutputStream . putNextEntry ( entry ) ; jarOutputStream . write ( content . getBytes ( ) ) ; jarOutputStream . closeEntry ( ) ; jarOutputStream . close ( ) ; return byteArrayOutputStream . toByteArray ( ) ; }
create a jar using the given file contents and with the given file name .
