Hızlı Konu Açma

Hızlı Konu Açmak için tıklayınız.

Son Mesajlar

Konulardaki Son Mesajlar

Reklam

Forumda Reklam Vermek İçin Bize Ulaşın

Dosya Bölme İşlemi

BlackKey

Üye
Fenerbahçe
Kayıtlı Üye
Katılım
12 Eylül 2014
Mesajlar
167
Tepkime puanı
0
Puanları
0
Kod:
[COLOR=#B5B5B5][FONT=tahoma]import java.io.*; [/FONT][/COLOR]import java.util.zip.*; 

class Main { 
public static **** main(String[] args) { 
if (args.length != 2) { 
System.err.println("Usage: java Main <input> <output>"); 
System.exit(-1); 
} 
try { 
FileInputStream in = new FileInputStream(args[0]); 

// Create compressed stream that writes to byte array output stream 
ByteArrayOutputStream b = new ByteArrayOutputStream(); 
GZIPOutputStream out = new GZIPOutputStream(b); 

byte[] buf = new byte[512]; 
int howmany; 
while ((howmany = in.read(buf)) > 0) { 
out.write(buf, 0, howmany); 
} 
in.close(); 
out.flush(); 
byte[] compressedBytes = b.toByteArray(); // get byte array 
b.writeTo(new FileOutputStream(args[1])); // write to file 
out.close(); // closes both out and b 
System.out.println("compressed size: " + compressedBytes.length); 
// ... do something with byte array 

} catch (IOException e) { 
System.out.println(e); 
} 
}  [COLOR=#B5B5B5][FONT=tahoma]}[/FONT][/COLOR]
 

Users Who Are Viewing This Konu (Users: 0, Guests: 1)

Üst