Folge dem Video um zu sehen, wie unsere Website als Web-App auf dem Startbildschirm installiert werden kann.
Anmerkung: Diese Funktion ist in einigen Browsern möglicherweise nicht verfügbar.
* created on 26.02.2005@02:02:11
*/
package de.tutorials;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.InputStream;
import java.util.jar.JarFile;
import java.util.zip.ZipEntry;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
/**
* @author Administrator
*
*/
public class JarFileReaderExample {
/**
* @param args
*/
public static void main(String[] args) throws Exception {
File file = new File("C:/Programme/Java/jdk1.5.0_01/jre/lib/rt.jar");
JarFile jarFile = new JarFile(file);
ZipEntry entry = jarFile
.getEntry("javax/swing/plaf/metal/icons/Error.gif");
InputStream is = jarFile.getInputStream(entry);
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[8192];
int len = 0;
while ((len = is.read(buffer)) > 0) {
baos.write(buffer, 0, len);
}
is.close();
new JFrame() {
{
setDefaultCloseOperation(EXIT_ON_CLOSE);
getContentPane().add(
new JLabel(new ImageIcon(baos.toByteArray())));
pack();
}
}.setVisible(true);
}
}