Convert InputStream to byte array in Java

如何将整个InputStream读入字节数组? You can use Apache Commons IO to handle this and similar tasks. The IOUtils type has a static method to read an InputStream and return a byte[] . InputStream is; byte[] bytes = IOUtils.toByteArray(is); Internally this creates a ByteArrayOutputStream and copies the bytes to the output, then calls toByteArray() . It handles large files by copying the bytes i

用Java将InputStream转换为字节数组

如何将整个InputStream读入字节数组? 你可以使用Apache Commons IO来处理这个和类似的任务。 IOUtils类型有一个静态方法来读取一个InputStream并返回一个byte[] 。 InputStream is; byte[] bytes = IOUtils.toByteArray(is); 在内部,这将创建一个ByteArrayOutputStream并将这些字节复制到输出,然后调用到ByteArrayOutputStream toByteArray() 。 它通过复制4KiB块中的字节来处理大文件。 您需要从InputStream读取每个

JavaFX PrintAPI wrong PaperSource

I'm using the JavaFx Print-Dialog to customize the print job. All properties will be stored in the PrinterJob#JobSettings variable, but when I receive the paper source from the jobSetting the paper source is always the default. How can I get the paper source that I set? Here is a short example: public class PrinterPaperSourceTest extends Application { public static void main(String[

JavaFX PrintAPI错误的PaperSource

我正在使用JavaFx Print-Dialog来定制打印作业。 所有属性都将存储在PrinterJob#JobSettings变量中,但是当我从jobSetting接收纸张来源时,纸张来源始终是默认设置。 我如何获取我设置的纸张来源? 这是一个简短的例子: public class PrinterPaperSourceTest extends Application { public static void main(String[] args) { launch( args ); } @Override public void start(Stage primaryStag

Android Studio 2.2 Preview 3 Layout Error

I just updated my android studio to the 2.2 Preview 3 and on trying the new constraint layout i placed a edittext into the layout and ran the app on my phone but this is what i got i then tried converting the constraint layout back to how the code was before constraint layout , the results were the same. activity_main.xml <?xml version="1.0" encoding="utf-8"?> <android.support.desig

Android Studio 2.2 Preview 3布局错误

我刚刚更新了我的android studio 2.2 Preview 3 ,并尝试新的constraint layout我放置了一个edittext到布局中,然后在手机上运行应用程序,但这是我得到的 然后我试图转换的constraint layout回到代码是如何之前constraint layout ,结果都是一样的。 activity_main.xml <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/

Stream<Stream>: flatMap vs. reduce

This question already has an answer here: Why filter() after flatMap() is “not completely” lazy in Java streams? 6 answers From the implementation of flatMap in openJDK, what I understand is that flatMap pushes the whole content of the incoming stream downstream: result.sequential().forEach(downstreamAsInt); On the other hand, Stream::concat seems to be handling the pull and not sending ev

Stream <Stream>:flatMap与reduce

这个问题在这里已经有了答案: 为什么在flatMap()之后的filter()在Java流中“不完全”是懒惰的? 6个答案 从openJDK中的flatMap的实现中,我了解到, flatMap会将传入流的所有内容向下游推送: result.sequential().forEach(downstreamAsInt); 另一方面, Stream::concat似乎在处理pull,并不是一次发送所有内容。 我怀疑你的测试没有显示出全貌: 在flatMap ,仅在第一个流被耗尽时才考虑第二个流。 在reduce ,

How to use Opencv FeatureDetecter on tiny images

I am using Opencv 3 in Java, I am trying to find small images(like 25x25 pixels) on other image. But FeatureDetector detection (0,0) size Mat on small image. Mat smallImage = ... FeatureDetector detector = FeatureDetector.create(FeatureDetector.ORB); DescriptorExtractor descriptor = DescriptorExtractor.create(DescriptorExtractor.ORB); DescriptorMatcher matcher = DescriptorMatch

如何在小图片上使用Opencv FeatureDetecter

我在Java中使用Opencv 3,我试图在其他图像上找到小图像(如25x25像素)。 但FeatureDetector检测(0,0)大小小图片上的Mat。 Mat smallImage = ... FeatureDetector detector = FeatureDetector.create(FeatureDetector.ORB); DescriptorExtractor descriptor = DescriptorExtractor.create(DescriptorExtractor.ORB); DescriptorMatcher matcher = DescriptorMatcher.create(DescriptorMatcher.BRUTEFORCE_H

Location not populated on Spring Social Facebook

I'm trying to get user location in Spring Social Facebook: Facebook fb = ((Facebook) connection.getApi()); Page pg = fb.pageOperations().getPage(fb.userOperations().getUserProfile().getLocation().getId()); The problem is that pg.getLocation() returns null . I also tried with fb.fetchObject(fb.userOperations().getUserProfile().getLocation().getId(), org.springframework.social.facebook.api

未在Spring社交Facebook上填充位置

我试图在Spring社交Facebook上获取用户位置: Facebook fb = ((Facebook) connection.getApi()); Page pg = fb.pageOperations().getPage(fb.userOperations().getUserProfile().getLocation().getId()); 问题是pg.getLocation()返回null 。 我也试过 fb.fetchObject(fb.userOperations().getUserProfile().getLocation().getId(), org.springframework.social.facebook.api.Location.class) 但它确实填充了名称,而不是国

Is an "atomic" interrupt check possible in java?

If using following "idiom" with interruption in Java, for example from this answer. while (!Thread.currentThread().isInterrupted()) { try { Object value = queue.take(); handle(value); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } Where take is a blocking operation, can an interrupt not be ignored for the time being if an

是否可以在java中进行“原子”中断检查?

如果在Java中使用以下“成语”,例如从此答案中。 while (!Thread.currentThread().isInterrupted()) { try { Object value = queue.take(); handle(value); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } 如果take是阻塞操作,那么如果在Thread.currentThread().isInterrupted()和调用queue.take()之间的中断“到达”之间暂时不会忽略中断Thread.currentThre

Open Source Software For Transcribing Speech in Audio Files

Can anyone recommend reliable open source software for transcribing English speech in wav files? The two main programs I've researched are Sphinx and Julius, but I've never been able to get either to work, and the documentation with each on transcribing files is sketchy at best. I'm developing on 64-bit Ubuntu 10.04, whose repos include sphinx2 and julius, as well as voxforge's

用于在音频文件中转录语音的开源软件

任何人都可以推荐可靠的开源软件在wav文件中转录英语语音吗? 我研究的两个主要程序是狮身人面像和朱利叶斯,但我从来没有能够得到任何工作,每个转录文件的文档都是粗略的。 我正在开发64位Ubuntu 10.04,其中包括sphinx2和julius,以及voxforge的julius英语声学模式。 我专注于转录文件,而不是直接处理来自麦克风的声音,因为我已经放弃期望像这样的项目能够与Ubuntu的音响系统一起工作。 这不是对付Ubuntu的敲门声,因

Continuous speech recognition in android app without google popup

I am working on a project on "Home Automation" system with Android app and Microcontroller , connecting them through Bluetooth module. I have incorporated "speech to text" for voice commands. Although , it works well with the built-in google speech recognition api. All I need is a continuous speech recognition and without the google voice pop-up. I have seen a similar app

在没有谷歌弹出窗口的android应用程序中进行连续语音识别

我正在使用Android应用程序和微控制器开展“家庭自动化”系统项目,并通过蓝牙模块连接它们。 我已经将“语音到文本”纳入了语音命令。 虽然,它与内置的谷歌语音识别API运作良好。 我需要的只是一个持续的语音识别,并且不会弹出谷歌语音。 我在Playstore“speechnotes”上看到了一个类似的应用程序,它正是我想要开发的。 它完全离线。 您应该尝试Droid Speech,它支持连续语音识别,并且如果在设备中安装了所需语言的语音包

Accuracy is poor in speech recognition using pocket Sphinix

I have run pocketsphinix demo example from http://ucla.jamesyxu.com/?p=118.But, I found accuracy of recognition of words is very poor.I copy the acoustic model from pocketsphinix8.0 ...pocketsphinxmodelhmm and ..lm folder to sdcard of phone.It recognize limited few words not sentences. My questions are following 1)How can I improve accuracy ? 2)Is there need to change acoustic model and dict

使用口袋Sphinix进行语音识别的准确度很差

我已经从http://ucla.jamesyxu.com/?p=118运行pocketsphinix演示例子。但是,我发现文字识别的准确性非常差。我从pocketsphinix8.0复制声学模型... pocketsphinx model hmm和.. lm文件夹到手机的SD卡。它识别有限的几个单词而不是句子。 我的问题如下 1)我如何提高准确性? 2)是否需要改变声学模型和字典(在hmm和lm文件夹中)如果是,我怎样才能改变模型和字典。是否有任何其他程序需要遵循添加模型和字典。 我也从