Merhaba, java'da yeniyim ve java.util.zip
numaralı telefondan Deflater
kullanarak bir bayt akışını sıkıştırmaya çalışıyorum. Oracle site'dan bir örnek izledim. Bu kodu çalıştırdığınızda bana setInput()
, finish()
, deflate()
ve end()
belirten bir hata verirjava.util.zip dosyasında nasıl kullanılır?
try {
// Encode a String into bytes
String inputString = "blahblahblah";
byte[] input = inputString.getBytes("UTF-8");
// Compress the bytes
byte[] output = new byte[100];
Deflater compresser = new Deflater();
compresser.setInput(input);
compresser.finish();
int compressedDataLength = compresser.deflate(output);
compresser.end();
// Decompress the bytes
Inflater decompresser = new Inflater();
decompresser.setInput(output, 0, compressedDataLength);
byte[] result = new byte[100];
int resultLength = decompresser.inflate(result);
decompresser.end();
// Decode the bytes into a String
String outputString = new String(result, 0, resultLength, "UTF-8");
} catch(java.io.UnsupportedEncodingException ex) {
// handle
} catch (java.util.zip.DataFormatException ex) {
// handle
}
tanımlı değil. İşte java.util.zip
ithal ve Oracle site.It içinde Dokümanlarından baktım hata mesajı
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The method setInput(byte[]) is undefined for the type Deflater
The method finish() is undefined for the type Deflater
The method deflate(byte[]) is undefined for the type Deflater
The method end() is undefined for the type Deflater
at Deflater.main(Deflater.java:16)
olan bu yöntemlerin var diyor.
Sorunun nerede olduğunu çözemiyor. Birisi yardım edebilir.
Tam olarak aynı kodu eğiticiler noktasında çevrimiçi çalıştırdım ve mükemmel çalıştı, Yöntemler, Deflate sınıfında mevcut. Java kurulumunda bir hata var mı, Lütfen Enfekte et ve Deflat'ı ayrı ayrı almayı deneyin. –