outputstream

android: copy internal storage image to ImageView?

为君一笑 提交于 2020-06-01 06:56:11
问题 Image is copied from assets directory to internal storage directory and new image is successfully found in the directory using Android Studio's Device File Explorer. But UI is blank. What am I missing here? public class MainActivity extends AppCompatActivity { Context context; private final String assetImage = "qtest1.png"; boolean isDirectoryCreated; private ImageView myImageView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);

Preferred way to use Java ZipOutputStream and BufferedOutputStream

被刻印的时光 ゝ 提交于 2020-05-09 18:37:08
问题 In Java does it matter whether I instantiate a ZipOutputStream first, or the BufferedOutputStream first? Example: FileOutputStream dest = new FileOutputStream(file); ZipOutputStream zip = new ZipOutputStream(new BufferedOutputStream(dest)); // use zip output stream to write to Or: FileOutputStream dest = new FileOutputStream(file); BufferedOutputStream out = new BufferedOutputStream(new ZipOutputStream(dest)); // use buffered stream to write to In my non-scientific timings I can't seem to

wkhtmtopdf--高分辨率转HTML成PDF(一)

我的梦境 提交于 2020-03-18 17:35:12
3 月,跳不动了?>>> 一、需求 这次工作中遇到一个需求,要求把网页转换为PDF,穷极了很多的方法,包括尝试了itextsharp来转换,虽然可以实现,但是分辨率和效率并不理想;偶然间看到网友的一篇关于wkhtmtopdf的用法,虽然说的不是很清楚,但是总算发现了这么一个方法,研究了两天,大概了解了一些做法,现在记录下来,以便以后可以用到,还有,有需要的朋友也可以参考下~~ wkhtmltopdf:利用 webkit 内核将 HTML 转为 PDF。webkit 是一个高效、开源的浏览器内核,包括 Chrome 和 Safari 在内的(当然也包括国内那些极速啥的)浏览器都使用了这个内核。Chrome 打印当前网页的功能,其中有一个选项就是直接“保存为 PDF”。   二、安装篇 工欲善其事,必先利其器。现在,我们先来研究下这个工具的一些用法,为后面的代码篇做铺垫~ 1.  首先 下载安装包,官方地址 : http://code.google.com/p/wkhtmltopdf/downloads/list 点击安装 注意:安装路径不能包含空格 (如果要卸载,就到刚刚安装的文件夹下找uninstall.exe执行即可)   Technorati 标签: wkhtmtopdf , HTMLTOPDF , HTML转换PDF , outputStream 来源: oschina 链接

Android Bluetooth: java.io.IOException: Service discovery failed

随声附和 提交于 2020-01-22 15:25:12
问题 I'm trying to develop an Android application which transfers images from one device to another. The received image would then be shown on the ImageView inside my application. To achieve my task, I thought to send a byte array of the bitmap. I'm able to get the first image on the imageview. But, as soon as I click on the button to send another image the application fails to send the bitmap. It shows me an exception "java.io.IOException: Service fiscovery failed." To send any image successfully

Saxon XSLT Transformation: How to close outputstream when failing during transformation

☆樱花仙子☆ 提交于 2020-01-22 02:33:08
问题 I want to do a XSLT transformation with multiple output files. There for I used "xsl:result-document". When the transformation fails, all output files should be deleted. But if the generation of a document created by "xsl:result-document" fails, my program not able to delete this document anymore. I think the reason is, that "xsl:result-document" create a different OutputStream. Does anyone know how to close all output streams? Edit: I use Saxon 9.5 to do the transformation. Please see below

Java copy part of InputStream to OutputStream

Deadly 提交于 2020-01-13 04:47:13
问题 I have a file with 3236000 bytes and I want to read 2936000 from start and write to an OutputStream InputStream is = new FileInputStream(file1); OutputStream os = new FileOutputStream(file2); AFunctionToCopy(is,os,0,2936000); /* a function or sourcecode to write input stream 0to2936000 bytes */ I can read and write byte by byte, but it's to slow (i think) from buffered reading How can do I copy it? 回答1: public static void copyStream(InputStream input, OutputStream output, long start, long end

Bluetooth-connection; can't send strings properly

狂风中的少年 提交于 2020-01-12 19:09:23
问题 I have troubles with my program when i need to send Strings from my server bluetooth-socket to my client bluetooth-socket. Everything works fine as long as I am only sending one String at a time (for example chatting) but if I need to write more Strings at a short period of time (to interchange informations), the Strings will not get seperated from the client code. For example if I'm sending "FirstUser" and right after that "SecondUser" the client does not read "FirstUser" and then

Bluetooth-connection; can't send strings properly

╄→гoц情女王★ 提交于 2020-01-12 19:08:30
问题 I have troubles with my program when i need to send Strings from my server bluetooth-socket to my client bluetooth-socket. Everything works fine as long as I am only sending one String at a time (for example chatting) but if I need to write more Strings at a short period of time (to interchange informations), the Strings will not get seperated from the client code. For example if I'm sending "FirstUser" and right after that "SecondUser" the client does not read "FirstUser" and then

Bluetooth-connection; can't send strings properly

試著忘記壹切 提交于 2020-01-12 19:08:10
问题 I have troubles with my program when i need to send Strings from my server bluetooth-socket to my client bluetooth-socket. Everything works fine as long as I am only sending one String at a time (for example chatting) but if I need to write more Strings at a short period of time (to interchange informations), the Strings will not get seperated from the client code. For example if I'm sending "FirstUser" and right after that "SecondUser" the client does not read "FirstUser" and then

copying files in android with input/output stream: the good and the bad way

試著忘記壹切 提交于 2020-01-07 09:49:19
问题 i have made this two routines to copy files using inputstream and outpustream. they are quite the same however the second one rise ArrayIndexOutOfBoundsException while the first one works flawlessly and i don't know why: public void CopyStream(long size, InputStream is, OutputStream os) { final int buffer_size = 4096; byte[] bytes = new byte[buffer_size]; try { int count,prog=0; while ((count = is.read(bytes)) != -1) { os.write(bytes, 0, count); //write buffer prog = prog + count;