我如何正确地将字节压缩到a ByteArrayOutputStream然后使用ByteArrayInputStream?读取?我有以下方法:
private byte[] getZippedBytes(final String fileName, final byte[] input) throws Exception {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ZipOutputStream zipOut = new ZipOutputStream(bos);
ZipEntry entry = new ZipEntry(fileName);
entry.setSize(input.length);
zipOut.putNextEntry(entry);
zipOut.write(input, 0, input.length);
zipOut.closeEntry();
zipOut.close();
//Turn right around and unzip what we just zipped
ZipInputStream zipIn = new ZipInputStream(new ByteArrayInputStream(bos.toByteArray()));
while((entry = zipIn.getNextEntry()) != null) {
assert entry.getSize() >= 0;
}
return bos.toByteArray();
}
Run Code Online (Sandbox Code Playgroud)
当我执行此代码时,底部的断言失败,因为entry.size是-1.我不明白为什么提取的实体与压缩的实体不匹配.
java zip bytearrayoutputstream bytearrayinputstream zipoutputstream
保持nvarchar字段唯一的好方法是什么.我有一个存储mp3文件网址的字段.url长度可以是10个字符到4000之间的任何值.我试图创建一个索引,它说它不能创建索引,因为总长度超过900个字节.
如果该字段未编入索引,则搜索任何内容的速度都会很慢.我正在使用c#,asp.net mvc作为前端.
问候
Paraminder
I installed the 32 bit version of Mingw 4.7.2 (using the installer) on my Windows 7 64 bit. I use MinGW in an Eclipse C++ project in order to build a .dll file. So far everything works.
However I use this .dll to be included in a java project via JNI. And when I call a function of the .dll in the java project the exception "Exception in thread "main" java.lang.UnsatisfiedLinkError: D:\path\mylib.dll: Can't load IA 32-bit .dll on a AMD …
我正在尝试学习如何使用epoll()TCP 服务器应用程序,因为我期望有很多连接。
我尝试检查示例和教程,他们总是建议使用/设置添加epoll()为非阻塞套接字的套接字。
为什么?
有没有一种方法可以杀死中间的克隆操作?我将使用克隆来验证存储库?有没有其他方法来测试远程url/repository是否有效?
使用Google无法找到任何有用的信息.
我发现的所有人都在询问如何解决编译错误,例如
make: *** No rule to make target `/home/joe/[ubuntuTouch]/out/target/product/jewel/obj/SHARED_LIBRARIES/libril_intermediates/export_includes', needed by `/home/joe/[ubuntuTouch]/out/target/product/jewel/obj/EXECUTABLES/rild_intermediates/import_includes'. Stop.
Run Code Online (Sandbox Code Playgroud) 如何使用嵌套字段创建镶木地板文件?我有以下内容:
public static void main(String []args) throws IOException{
int fileNum = 10; //num of files constructed
int fileRecordNum = 50; //record num of each file
int rowKey = 0;
for(int i = 0; i < fileNum; ++ i ) {
Map<String, String> metas = new HashMap<>();
metas.put(HConstants.START_KEY, genRowKey("%10d", rowKey + 1));
metas.put(HConstants.END_KEY, genRowKey("%10d", rowKey + fileRecordNum));
ParquetWriter<Group> writer = initWriter("pfile/scanner_test_file" + i, metas);
for (int j = 0; j < fileRecordNum; ++j) {
rowKey ++;
Group group = sfg.newGroup().append("rowkey", genRowKey("%10d", …Run Code Online (Sandbox Code Playgroud) 我试图了解LoRaWAN 1.2规范中的三个神奇的LoRaWAN ID 。我的理解是:
DevEUI 就像一个MAC地址AppKey 就像一个公钥(大概...)AppEUI 就像一个端口号现在,我在理解由谁负责创建这些ID时遇到了问题:
DevEUI 可以从LoRa芯片内部ID寄存器生成(我正在使用村田制作所的ABZ类型芯片)AppKey:每个端节点是否应该唯一?我应该选择一个随机的还是从LoRaWAN提供商那里问一个(例如Objenious)?AppEUI:每个终端节点应该公用(我想应该是)?我应该随机选择一个,还是向LoRaWAN提供商询问?我试图将TIF/TIFF图像转换为JPG,但工作正常但是对于很少的TIF图像我得到IllegalArgumentException:Bad endianness标记(不是0x4949或0x4d4d).
例外:
java.io.IOException: Bad endianness tag (not 0x4949 or 0x4d4d).
at com.sun.media.jai.codecimpl.CodecUtils.toIOException(CodecUtils.java:76)
at com.sun.media.jai.codecimpl.TIFFImageDecoder.getNumPages(TIFFImageDecoder.java:98)
at com.sun.media.jai.codecimpl.TIFFImageDecoder.decodeAsRenderedImage(TIFFImageDecoder.java:103)
at com.sun.media.jai.codec.ImageDecoderImpl.decodeAsRenderedImage(ImageDecoderImpl.java:140)
at com.pkg.jae.utils.GenericImageUtils.convertTiffToJpg(GenericImageUtils.java:35)
at com.pkg.jae.utils.GenericImageUtils.main(GenericImageUtils.java:92)
Caused by: java.lang.IllegalArgumentException: Bad endianness tag (not 0x4949 or 0x4d4d).
at com.sun.media.jai.codec.TIFFDirectory.getNumDirectories(TIFFDirectory.java:595)
at com.sun.media.jai.codecimpl.TIFFImageDecoder.getNumPages(TIFFImageDecoder.java:96)
... 4 more
Run Code Online (Sandbox Code Playgroud)
代码功能:
public static void convertTiffToJpg(String strTiffUrl,String strJpgFileDestinationUrl) throws Exception {
try {
FileSeekableStream obj_FileSeekableStream = new FileSeekableStream(new File(strTiffUrl));
ImageDecoder obj_ImageDecoder = ImageCodec.createImageDecoder(EXT_TIFFX, obj_FileSeekableStream, null);
RenderedImage obj_RenderedImage = obj_ImageDecoder.decodeAsRenderedImage();
JAI.create("filestore", obj_RenderedImage,strJpgFileDestinationUrl, EXT_JEPGX);
obj_RenderedImage = null;
obj_ImageDecoder = null;
obj_FileSeekableStream.close();
} catch …Run Code Online (Sandbox Code Playgroud) 我试图加快最初通过切换到C用Java编写的我TIFF编码器和编译的zlib 1.2.8与Z_SOLO定义和最低限度的C文件:adler32.c,crc32.c,deflate.c,trees.c和zutil.c.Java正在使用java.util.zip.Deflater.
我编写了一个简单的测试程序,用于评估压缩级别和速度方面的性能,并且考虑到更高级别所需的时间越来越多,压缩不会产生太大的影响.我也惊讶于Java在压缩和速度方面的表现实际上比Visual Studio Release-compile(VC2010)更好:
Java的:
Level 1 : 8424865 => 6215200 (73,8%) in 247 cycles.
Level 2 : 8424865 => 6178098 (73,3%) in 254 cycles.
Level 3 : 8424865 => 6181716 (73,4%) in 269 cycles.
Level 4 : 8424865 => 6337236 (75,2%) in 334 cycles.
Level 5 : 8424865 => 6331902 (75,2%) in 376 cycles.
Level 6 : 8424865 => 6333914 (75,2%) …Run Code Online (Sandbox Code Playgroud)