導航:首頁 > 文件處理 > gzip解壓命令

gzip解壓命令

發布時間:2022-01-25 23:54:21

A. 如何查看gzip 命令解壓後的文件

許可權不夠,做這個操作必須是-user student 用戶或超級用戶root,其他用戶都會報錯。

B. linux解壓zip文件的命令

linux怎麼解壓zip包,操作方法如下。

1、首先在電腦中,連接到linux遠程主機,並進入zip文件所在目錄,如下圖所示。

C. Linux解壓.gz的命令是什麼

D. 求後綴gzip的文件怎麼打開或解壓。

你可以下載一個7-zip 這是一個解壓文件~~!下完後,在點文件文件時,他會出現。點open....在點擊蹦出來的文件,就行了!

E. linux文將於目錄的壓縮和解壓縮命令:gzip壓縮文件

許可權不夠,做這個操作必須是-user student 用戶或超級用戶root,其他用戶都會報錯。

F. .rar.gzip文件怎麼解壓

先解壓gzip再看rar是擴展名還是文件名,是擴展名再解壓

G. linux下的gzip命令如何運用

linux下的gzip命令運用方法如下:

1、打開linux客戶端。


H. 急!如何解壓rar.gzip格式的文件,謝謝!

只有解壓RAR和ZIP的,沒有gzip的。用RAR可以解壓RAR和ZIP。gzip估計就別人改了後置名的,正常的只有zip的

I. 被壓縮為gzip格式的二進制數組如何解壓

直接編譯運行!!!
不知道你是要查看壓縮文件還是要解壓文件,所以發上來兩個。
第一個可以查看各個壓縮項目;
第二個可以解壓文件。
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import java.util.zip.*;
import javax.swing.*;
import javax.swing.filechooser.FileFilter;
class ZipTest {
public static void main(String[] args) {
ZipTestFrame frame = new ZipTestFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
class ZipTestFrame extends JFrame {

private JComboBox fileCombo;
private JTextArea fileText;
private String zipname;

public ZipTestFrame() {

setTitle("ZipTest");
setSize(400,300);

JMenuBar menuBar = new JMenuBar();
JMenu menu = new JMenu("File");

JMenuItem openItem = new JMenuItem("Open");
menu.add(openItem);
openItem.addActionListener(new OpenAction());

JMenuItem exitItem = new JMenuItem("Exit");
menu.add(exitItem);
exitItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
System.exit(0);
}
});

menuBar.add(menu);
setJMenuBar(menuBar);

fileText = new JTextArea();
fileCombo = new JComboBox();
fileCombo.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
loadZipFile((String)fileCombo.getSelectedItem());
}
});
add(fileCombo, BorderLayout.SOUTH);
add(new JScrollPane(fileText), BorderLayout.CENTER);
}

public class OpenAction implements ActionListener {
public void actionPerformed(ActionEvent event) {
JFileChooser chooser = new JFileChooser();
chooser.setCurrentDirectory(new File("."));
ExtensionFileFilter filter = new ExtensionFileFilter();
filter.addExtension(".zip");
filter.addExtension(".jar");
filter.setDescription("ZIP archives");
chooser.setFileFilter(filter);
int r = chooser.showOpenDialog(ZipTestFrame.this);
if(r == JFileChooser.APPROVE_OPTION) {
zipname = chooser.getSelectedFile().getPath();
scanZipFile();
}
}
}

J. 如何解壓.tar.gz gzip gz 類型文檔

java解壓縮.gz .zip .tar.gz等格式的壓縮包方法總結
1、.gz文件是linux下常見的壓縮格式。使用 java.util.zip.GZIPInputStream即可,壓縮是 java.util.zip.GZIPOutputStream

1 public static void unGzipFile(String sourcedir) {
2 String ouputfile = "";
3 try {
4 //建立gzip壓縮文件輸入流
5 FileInputStream fin = new FileInputStream(sourcedir);
6 //建立gzip解壓工作流
7 GZIPInputStream gzin = new GZIPInputStream(fin);
8 //建立解壓文件輸出流
9 ouputfile = sourcedir.substring(0,sourcedir.lastIndexOf('.'));
10 ouputfile = ouputfile.substring(0,ouputfile.lastIndexOf('.'));
11 FileOutputStream fout = new FileOutputStream(ouputfile);
12
13 int num;
14 byte[] buf=new byte[1024];
15
16 while ((num = gzin.read(buf,0,buf.length)) != -1)
17 {
18 fout.write(buf,0,num);
19 }
20
21 gzin.close();
22 fout.close();
23 fin.close();
24 } catch (Exception ex){
25 System.err.println(ex.toString());
26 }
27 return;
28 }

2、zip文件,使用java.util.zip.ZipEntry 和 java.util.zip.ZipFile

1 /**
2 * 解壓縮zipFile
3 * @param file 要解壓的zip文件對象
4 * @param outputDir 要解壓到某個指定的目錄下
5 * @throws IOException
6 */
7 public static void unZip(File file,String outputDir) throws IOException {
8 ZipFile zipFile = null;
9
10 try {
11 Charset CP866 = Charset.forName("CP866"); //specifying alternative (non UTF-8) charset
12 //ZipFile zipFile = new ZipFile(zipArchive, CP866);
13 zipFile = new ZipFile(file, CP866);
14 createDirectory(outputDir,null);//創建輸出目錄
15
16 Enumeration<?> enums = zipFile.entries();
17 while(enums.hasMoreElements()){
18
19 ZipEntry entry = (ZipEntry) enums.nextElement();
20 System.out.println("解壓." + entry.getName());
21
22 if(entry.isDirectory()){//是目錄
23 createDirectory(outputDir,entry.getName());//創建空目錄
24 }else{//是文件
25 File tmpFile = new File(outputDir + "/" + entry.getName());
26 createDirectory(tmpFile.getParent() + "/",null);//創建輸出目錄
27
28 InputStream in = null;
29 OutputStream out = null;
30 try{
31 in = zipFile.getInputStream(entry);;
32 out = new FileOutputStream(tmpFile);
33 int length = 0;
34
35 byte[] b = new byte[2048];
36 while((length = in.read(b)) != -1){
37 out.write(b, 0, length);
38 }
39
40 }catch(IOException ex){
41 throw ex;
42 }finally{
43 if(in!=null)
44 in.close();
45 if(out!=null)
46 out.close();
47 }
48 }
49 }
50
51 } catch (IOException e) {
52 throw new IOException("解壓縮文件出現異常",e);
53 } finally{
54 try{
55 if(zipFile != null){
56 zipFile.close();
57 }
58 }catch(IOException ex){
59 throw new IOException("關閉zipFile出現異常",ex);
60 }
61 }
62 }
63
64 /**
65 * 構建目錄
66 * @param outputDir
67 * @param subDir
68 */
69 public static void createDirectory(String outputDir,String subDir){
70 File file = new File(outputDir);
71 if(!(subDir == null || subDir.trim().equals(""))){//子目錄不為空
72 file = new File(outputDir + "/" + subDir);
73 }
74 if(!file.exists()){
75 if(!file.getParentFile().exists())
76 file.getParentFile().mkdirs();
77 file.mkdirs();
78 }
79 }

3、.tar.gz文件可以看做先用tar打包,再使用gz進行壓縮。
使用org.apache.tools.tar.TarEntry; org.apache.tools.tar.TarInputStream 和 org.apache.tools.tar.TarOutputStream

1 //------------------------------------------------------------------------------------------------------
2 /**
3 * 解壓tar.gz 文件
4 * @param file 要解壓的tar.gz文件對象
5 * @param outputDir 要解壓到某個指定的目錄下
6 * @throws IOException
7 */
8 public static void unTarGz(File file,String outputDir) throws IOException{
9 TarInputStream tarIn = null;
10 try{
11 tarIn = new TarInputStream(new GZIPInputStream(
12 new BufferedInputStream(new FileInputStream(file))),
13 1024 * 2);
14
15 createDirectory(outputDir,null);//創建輸出目錄
16
17 TarEntry entry = null;
18 while( (entry = tarIn.getNextEntry()) != null ){
19
20 if(entry.isDirectory()){//是目錄
21 entry.getName();
22 createDirectory(outputDir,entry.getName());//創建空目錄
23 }else{//是文件
24 File tmpFile = new File(outputDir + "/" + entry.getName());
25 createDirectory(tmpFile.getParent() + "/",null);//創建輸出目錄
26 OutputStream out = null;
27 try{
28 out = new FileOutputStream(tmpFile);
29 int length = 0;
30
31 byte[] b = new byte[2048];
32
33 while((length = tarIn.read(b)) != -1){
34 out.write(b, 0, length);
35 }
36
37 }catch(IOException ex){
38 throw ex;
39 }finally{
40
41 if(out!=null)
42 out.close();
43 }
44 }
45 }
46 }catch(IOException ex){
47 throw new IOException("解壓歸檔文件出現異常",ex);
48 } finally{
49 try{
50 if(tarIn != null){
51 tarIn.close();
52 }
53 }catch(IOException ex){
54 throw new IOException("關閉tarFile出現異常",ex);
55 }
56 }
57 }

使用到的包頭有:

1 import java.io.BufferedInputStream;
2 import java.io.File;
3 import java.io.FileInputStream;
4 import java.io.FileOutputStream;
5 import java.io.IOException;
6 import java.io.InputStream;
7 import java.io.OutputStream;
8
9 import java.nio.charset.Charset;
10 import java.util.Enumeration;
11 import java.util.zip.GZIPInputStream;
12 import java.util.zip.ZipEntry;
13 import java.util.zip.ZipFile;
14
15 import org.apache.tools.tar.TarEntry;
16 import org.apache.tools.tar.TarInputStream;
17 import org.apache.tools.tar.TarOutputStream;

閱讀全文

與gzip解壓命令相關的資料

熱點內容
塘管家源碼 瀏覽:698
台劇無邪什麼app可以看 瀏覽:586
筆記本配置伺服器怎麼連接 瀏覽:368
android代理上網設置 瀏覽:658
u盤加密不能顯示盤符 瀏覽:665
去伺服器玩什麼游戲 瀏覽:134
哪個同步盤支持多個文件夾 瀏覽:886
蘋果版的我的世界如何轉到安卓 瀏覽:274
linuxswap空間 瀏覽:409
如何搭建網路到各個伺服器 瀏覽:966
oa系統crm源碼 瀏覽:584
安卓生態為什麼一直很爛 瀏覽:147
數字加密傳輸流程 瀏覽:733
義隆8p單片機怎麼樣 瀏覽:271
什麼app能看到入團時間 瀏覽:898
建築設計資料集第三版pdf 瀏覽:150
怎麼知道郵箱伺服器是什麼 瀏覽:381
程序員有什麼可以玩的 瀏覽:601
當伺服器造轟炸機會發生什麼 瀏覽:94
什麼是mc伺服器ip地址 瀏覽:436