英文:
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);
}
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论