本文整理了Java中aQute.lib.osgi.Jar.write()
方法的一些代码示例,展示了Jar.write()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Jar.write()
方法的具体详情如下:
包路径:aQute.lib.osgi.Jar
类名称:Jar
方法名:write
[英]Convert a string to bytes with UTF8 and then output in max 72 bytes
[中]使用UTF8将字符串转换为字节,然后以最大72字节的格式输出
代码示例来源:origin: biz.aQute/bnd
/**
* Write out an entry, handling proper unicode and line length constraints
*
*/
private static void writeEntry(OutputStream out, String name, String value) throws IOException {
int n = write(out, 0, name + ": ");
n = write(out, n, value);
write(out, 0, "\r\n");
}
代码示例来源:origin: biz.aQute/bnd
/**
* Main function to output a manifest properly in UTF-8.
*
* @param manifest
* The manifest to output
* @param out
* The output stream
* @throws IOException
* when something fails
*/
public static void outputManifest(Manifest manifest, OutputStream out) throws IOException {
writeEntry(out, "Manifest-Version", "1.0");
attributes(manifest.getMainAttributes(), out);
TreeSet<String> keys = new TreeSet<String>();
for (Object o : manifest.getEntries().keySet())
keys.add(o.toString());
for (String key : keys) {
write(out, 0, "\r\n");
writeEntry(out, "Name", key);
attributes(manifest.getAttributes(key), out);
}
}
代码示例来源:origin: biz.aQute/aQute.bnd
public void write(OutputStream out) throws IOException {
jar.write(out);
}
代码示例来源:origin: biz.aQute/bnd
public void write(OutputStream out) throws Exception {
jar.write(out);
}
代码示例来源:origin: biz.aQute/bnd
public void write(String file) throws Exception {
write(new File(file));
}
代码示例来源:origin: biz.aQute/aQute.bnd
public void write(String file) throws Exception {
write(new File(file));
}
代码示例来源:origin: biz.aQute/bnd
/**
* Convert a string to bytes with UTF8 and then output in max 72 bytes
*
* @param out
* the output string
* @param i
* the current width
* @param s
* the string to output
* @return the new width
* @throws IOException
* when something fails
*/
private static int write(OutputStream out, int i, String s) throws IOException {
byte[] bytes = s.getBytes("UTF8");
return write(out, i, bytes);
}
代码示例来源:origin: biz.aQute/bnd
public void write(File file) throws Exception {
try {
OutputStream out = new FileOutputStream(file);
write(out);
out.close();
return;
} catch (Exception t) {
file.delete();
throw t;
}
}
代码示例来源:origin: biz.aQute/aQute.bnd
public void write(File file) throws Exception {
try {
OutputStream out = new FileOutputStream(file);
write(out);
out.close();
return;
} catch (Exception t) {
file.delete();
throw t;
}
}
代码示例来源:origin: org.fusesource.fabric/process-manager
/**
* Sets the executable class name in the given jar
*/
protected void setMainClass(ProcessConfig config, File installDir, File jarFile, int id, String mainClass) throws Exception {
File tmpFile = File.createTempFile("fuse-process-" + id, ".jar");
Files.copy(jarFile, tmpFile);
Jar jar = new Jar(tmpFile);
Attributes attributes = jar.getManifest().getMainAttributes();
attributes.putValue("Main-Class", mainClass);
jar.write(jarFile);
}
代码示例来源:origin: org.fusesource.fabric.fab/fab-osgi
public void run()
{
try
{
jar.write( pout );
}
catch( Exception e )
{
LOG.warn( "Bundle cannot be generated" );
}
finally
{
try
{
jar.close();
pout.close();
}
catch( IOException ignore )
{
// if we get here something is very wrong
LOG.error( "Bundle cannot be generated", ignore );
}
}
}
}.start();
代码示例来源:origin: io.fabric8.fab/fab-osgi
public void run()
{
try
{
jar.write( pout );
}
catch( Exception e )
{
LOG.warn( "Bundle cannot be generated" );
}
finally
{
try
{
jar.close();
pout.close();
}
catch( IOException ignore )
{
// if we get here something is very wrong
LOG.error( "Bundle cannot be generated", ignore );
}
}
}
}.start();
代码示例来源:origin: biz.aQute/bnd
public File saveBuild(Jar jar) throws Exception {
try {
String bsn = jar.getName();
File f = getOutputFile(bsn);
String msg = "";
if (!f.exists() || f.lastModified() < jar.lastModified()) {
reportNewer(f.lastModified(), jar);
f.delete();
if (!f.getParentFile().isDirectory())
f.getParentFile().mkdirs();
jar.write(f);
getWorkspace().changedFile(f);
} else {
msg = "(not modified since " + new Date(f.lastModified()) + ")";
}
trace(jar.getName() + " (" + f.getName() + ") " + jar.getResources().size() + " " + msg);
return f;
} finally {
jar.close();
}
}
代码示例来源:origin: biz.aQute/bnd
void applyPatch(String old, String patch, String newer) throws Exception {
Jar a = new Jar(new File(old));
Jar b = new Jar(new File(patch));
Manifest bm = b.getManifest();
String patchDelete = bm.getMainAttributes().getValue("Patch-Delete");
String patchVersion = bm.getMainAttributes().getValue("Patch-Version");
if (patchVersion == null) {
error("To patch, you must provide a patch bundle.\nThe given " + patch
+ " bundle does not contain the Patch-Version header");
return;
}
Collection<String> delete = split(patchDelete);
Set<String> paths = new HashSet<String>(a.getResources().keySet());
paths.removeAll(delete);
for (String path : paths) {
Resource br = b.getResource(path);
if (br == null)
b.putResource(path, a.getResource(path));
}
bm.getMainAttributes().putValue("Bundle-Version", patchVersion);
b.write(new File(newer));
a.close();
b.close();
}
代码示例来源:origin: biz.aQute/aQute.bnd
void applyPatch(String old, String patch, String newer) throws Exception {
Jar a = new Jar(new File(old));
Jar b = new Jar(new File(patch));
Manifest bm = b.getManifest();
String patchDelete = bm.getMainAttributes().getValue("Patch-Delete");
String patchVersion = bm.getMainAttributes().getValue("Patch-Version");
if (patchVersion == null) {
error("To patch, you must provide a patch bundle.\nThe given "
+ patch
+ " bundle does not contain the Patch-Version header");
return;
}
Collection<String> delete = split(patchDelete);
Set<String> paths = new HashSet<String>(a.getResources().keySet());
paths.removeAll(delete);
for (String path : paths) {
Resource br = b.getResource(path);
if (br == null)
b.putResource(path, a.getResource(path));
}
bm.getMainAttributes().putValue("Bundle-Version", patchVersion);
b.write(new File(newer));
a.close();
b.close();
}
代码示例来源:origin: biz.aQute/bnd
void createPatch(String old, String newer, String patch) throws Exception {
Jar a = new Jar(new File(old));
Manifest am = a.getManifest();
Jar b = new Jar(new File(newer));
Manifest bm = b.getManifest();
Set<String> delete = newSet();
for (String path : a.getResources().keySet()) {
Resource br = b.getResource(path);
if (br == null) {
trace("DELETE %s", path);
delete.add(path);
} else {
Resource ar = a.getResource(path);
if (isEqual(ar, br)) {
trace("UNCHANGED %s", path);
b.remove(path);
} else
trace("UPDATE %s", path);
}
}
bm.getMainAttributes().putValue("Patch-Delete", join(delete, ", "));
bm.getMainAttributes().putValue("Patch-Version",
am.getMainAttributes().getValue("Bundle-Version"));
b.write(new File(patch));
a.close();
a.close();
}
代码示例来源:origin: biz.aQute/aQute.bnd
void createPatch(String old, String newer, String patch) throws Exception {
Jar a = new Jar(new File(old));
Manifest am = a.getManifest();
Jar b = new Jar(new File(newer));
Manifest bm = b.getManifest();
Set<String> delete = newSet();
for (String path : a.getResources().keySet()) {
Resource br = b.getResource(path);
if (br == null) {
trace("DELETE %s", path);
delete.add(path);
} else {
Resource ar = a.getResource(path);
if (isEqual(ar, br)) {
trace("UNCHANGED %s", path);
b.remove(path);
} else
trace("UPDATE %s", path);
}
}
bm.getMainAttributes().putValue("Patch-Delete", join(delete, ", "));
bm.getMainAttributes().putValue("Patch-Version",
am.getMainAttributes().getValue("Bundle-Version"));
b.write(new File(patch));
a.close();
a.close();
}
代码示例来源:origin: biz.aQute/bnd
jar.write(out);
} finally {
out.close();
代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.entityhub.indexing.core
jar.write(new File(config.getDistributionFolder(),
CONFIG_PACKAGE+config.getName()+"-1.0.0.jar"));
} catch (Exception e) {
代码示例来源:origin: apache/stanbol
jar.write(new File(config.getDistributionFolder(),
CONFIG_PACKAGE+config.getName()+"-1.0.0.jar"));
} catch (Exception e) {
内容来源于网络,如有侵权,请联系作者删除!