如何从 xml.gz 文件中提取 XML?

huangapple go评论67阅读模式
英文:

How to extract xml from xml.gz?

问题

我正在使用一台运行Windows 10的计算机,我有一个文件,我想在Java应用程序中使用它。让我们把这个文件称为example.xml.gz。我想将其转换为一个XML文件,以便在Eclipse中查看数据,但是我不知道如何提取数据。我应该解压它吗?如果是这样,应该如何解压?

英文:

I'm using a Windows 10 computer and I have a file that I want to use in a Java application. Let's call the file example.xml.gz. I want to convert it to an XML file so I can view the data in Eclipse, but I can't figure out how to extract the data. Do I unzip it, if so how?

答案1

得分: 1

打开 gitbash,进入存放 xml.gz 文件的目录,使用:

gunzip example.xml.gz

然后 XML 文件将被解压,你可以打开该 xml 文件。

英文:

Open gitbash and in the dir where the xml.gz file is located use:

gunzip example.xml.gz

then the XML file will be extracted and you can open the xml file.

答案2

得分: 0

以下是您要翻译的内容:

您可以使用以下简单方法在Java中解压缩文件:

public static void gunzip(Path fin, Path fout) throws IOException {
    System.out.println("解压缩 " + fin + " -> " + fout);
    try (final OutputStream out = Files.newOutputStream(fout);
         final InputStream in = new GZIPInputStream(Files.newInputStream(fin))) {
        in.transferTo(out);
    }
}
英文:

You can gunzip a file in Java with this simple method:

public static void gunzip(Path fin, Path fout) throws IOException {
    System.out.println("GUNZIP "+fin+" -> "+fout);
    try(final OutputStream out = Files.newOutputStream(fout);
        final InputStream in   = new GZIPInputStream(Files.newInputStream(fin))) {
        in.transferTo(out);
    }
}

huangapple
  • 本文由 发表于 2020年9月14日 03:14:34
  • 转载请务必保留本文链接:https://go.coder-hub.com/63874613.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定