src/jdk.jpackage/linux/classes/jdk/jpackage/internal/DesktopIntegration.java
branchJDK-8200758-branch
changeset 58696 61c44899b4eb
parent 58647 2c43b89b1679
child 58762 0fe62353385b
equal deleted inserted replaced
58695:64adf683bc7b 58696:61c44899b4eb
    29 import java.nio.file.Path;
    29 import java.nio.file.Path;
    30 import java.util.*;
    30 import java.util.*;
    31 import java.util.stream.Collectors;
    31 import java.util.stream.Collectors;
    32 import java.util.stream.Stream;
    32 import java.util.stream.Stream;
    33 import javax.imageio.ImageIO;
    33 import javax.imageio.ImageIO;
    34 import javax.xml.stream.XMLOutputFactory;
       
    35 import javax.xml.stream.XMLStreamException;
    34 import javax.xml.stream.XMLStreamException;
    36 import javax.xml.stream.XMLStreamWriter;
    35 import javax.xml.stream.XMLStreamWriter;
    37 import static jdk.jpackage.internal.LinuxAppBundler.ICON_PNG;
    36 import static jdk.jpackage.internal.LinuxAppBundler.ICON_PNG;
    38 import static jdk.jpackage.internal.LinuxAppImageBuilder.DEFAULT_ICON;
    37 import static jdk.jpackage.internal.LinuxAppImageBuilder.DEFAULT_ICON;
    39 import static jdk.jpackage.internal.OverridableResource.createResource;
    38 import static jdk.jpackage.internal.OverridableResource.createResource;
   351 
   350 
   352         xml.writeEndElement();
   351         xml.writeEndElement();
   353     }
   352     }
   354 
   353 
   355     private void createFileAssociationsMimeInfoFile() throws IOException {
   354     private void createFileAssociationsMimeInfoFile() throws IOException {
   356         XMLOutputFactory xmlFactory = XMLOutputFactory.newInstance();
   355         IOUtils.createXml(mimeInfoFile.srcPath(), xml -> {
   357 
       
   358         try (Writer w = new BufferedWriter(new FileWriter(
       
   359                 mimeInfoFile.srcPath().toFile()))) {
       
   360             XMLStreamWriter xml = xmlFactory.createXMLStreamWriter(w);
       
   361 
       
   362             xml.writeStartDocument();
       
   363             xml.writeStartElement("mime-info");
   356             xml.writeStartElement("mime-info");
   364             xml.writeNamespace("xmlns",
   357             xml.writeDefaultNamespace(
   365                     "http://www.freedesktop.org/standards/shared-mime-info");
   358                     "http://www.freedesktop.org/standards/shared-mime-info");
   366 
   359 
   367             for (var assoc : associations) {
   360             for (var assoc : associations) {
   368                 appendFileAssociation(xml, assoc);
   361                 appendFileAssociation(xml, assoc);
   369             }
   362             }
   370 
   363 
   371             xml.writeEndElement();
   364             xml.writeEndElement();
   372             xml.writeEndDocument();
   365         });
   373             xml.flush();
       
   374             xml.close();
       
   375 
       
   376         } catch (XMLStreamException ex) {
       
   377             Log.verbose(ex);
       
   378             throw new IOException(ex);
       
   379         }
       
   380     }
   366     }
   381 
   367 
   382     private Map<String, Path> createFileAssociationIconFiles() throws
   368     private Map<String, Path> createFileAssociationIconFiles() throws
   383             IOException {
   369             IOException {
   384         Map<String, Path> mimeTypeWithIconFile = new HashMap<>();
   370         Map<String, Path> mimeTypeWithIconFile = new HashMap<>();