Tag: bytearray

byte 以Java文件格式

使用Java: 我有一个byte[]代表一个文件。 如何将其写入文件(即C:\myfile.pdf ) 我知道这是用InputStream完成的,但我似乎无法解决这个问题。

在C#中将大文件读入字节数组的最佳方法是什么?

我有一个Web服务器,它将读取大的二进制文件(几兆字节)成字节数组。 服务器可能会同时读取多个文件(不同的页面请求),所以我正在寻找最优化的方式来做到这一点,而不用过多的CPU。 代码是否足够好? public byte[] FileToByteArray(string fileName) { byte[] buff = null; FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fs); long numBytes = new FileInfo(fileName).Length; buff = br.ReadBytes((int) numBytes); return buff; }

如何将字节数组转换为string

我用两个string创build了一个字节数组。 如何将字节数组转换为string? var binWriter = new BinaryWriter(new MemoryStream()); binWriter.Write("value1"); binWriter.Write("value2"); binWriter.Seek(0, SeekOrigin.Begin); byte[] result = reader.ReadBytes((int)binWriter.BaseStream.Length); 我想将result转换为string。 我可以用BinaryReader来做。 但我不能使用BinaryReader (它不支持)。

如何将byte 转换为C#中的stream?

如何将byte[]数组转换为C#中的stream?

将字节数组转换为string(Java)

我在Google app Engine中编写一个Web应用程序。 它允许人们基本上编辑存储为.html文件的BLOB代码。 我使用fetchData来返回文件中所有字符的一个byte[] 。 我试图打印到一个HTML为了让用户编辑HTML代码。 一切都很好! 这是我现在唯一的问题: 字节数组在转换回string时遇到一些问题。 聪明的引号和几个字符出来看起来很时髦。 (?的或日本的符号等)具体来说,我看到有几个字节有负值导致的问题。 智能报价在字节数组中回到-108和-109 。 为什么是这样的,我怎样才能解码负字节显示正确的字符编码?

如何将hex转换为字节数组?

我复制和粘贴这个二进制数据的SQL Server,我无法在这个时候查询。 0xBAC893CAB8B7FE03C927417A2A3F6A60BD30FF35E250011CB25507EBFCD5223B 我如何将它转换回在C#中的字节数组?

在JSF页面中将图像显示为来自数据库的byte 图像

我有从数据库的byte[]图像内容。 private byte[] image; 如何在JSF页面中将该字节数组显示为真正的graphics图像?

PDF Blob没有显示内容,Angular 2

我有问题非常类似于这个PDF Blob – popup窗口没有显示的内容 ,但我使用Angular 2.有问题的答案是设置responseType为arrayBuffer,但它不适用于Angular 2,错误是reponseType不存在于RequestOptionsArgstypes中。 我也试图通过BrowserXhr扩展它,但仍然不工作( https://github.com/angular/http/issues/83 )。 我的代码是: createPDF(customerServiceId: string) { console.log("Sending GET on " + this.getPDFUrl + "/" + customerServiceId); this._http.get(this.getPDFUrl + '/' + customerServiceId).subscribe( (data) => { this.handleResponse(data); }); } 和handleResponse方法: handleResponse(data: any) { console.log("[Receipt service] GET PDF byte array " + JSON.stringify(data)); var file = new Blob([data._body], { type: […]

将字节数组转换为bitmapimage

我打算将字节数组转换为System.Windows.Media.Imaging.BitmapImage并在图像控件中显示BitmapImage 。 当我使用第一个代码时,注意到会发生! 没有错误,没有图像显示。 但是,当我使用第二个,它工作正常! 任何人都可以说是怎么回事? 第一个代码在这里: public BitmapImage ToImage(byte[] array) { using (System.IO.MemoryStream ms = new System.IO.MemoryStream(array)) { BitmapImage image = new BitmapImage(); image.BeginInit(); image.StreamSource = ms; image.EndInit(); return image; } } 第二个代码在这里: public BitmapImage ToImage(byte[] array) { BitmapImage image = new BitmapImage(); image.BeginInit(); image.StreamSource = new System.IO.MemoryStream(array); image.EndInit(); return image; }

如何从字节数组创build位图?

我search了关于字节数组的所有问题,但是我总是失败。 我从来没有编码C#我在这方面是新的。 你能帮我怎么从字节数组中创build图像文件。 这是我的函数,它存储字节数组名为imageData public void imageReady( byte[] imageData, int fWidth, int fHeight))