bytearray

java null pointer exception

hi, I'm getting java.lang.NullPointerException at while ((len = in.read(buf , 0 , buf.length)) >= 0) in following method: public void copy(String src, File dst) throws IOException { InputStream in = getClass().getResourceAsStream(src); OutputStream out = new FileOutputStream(dst); byte[] buf = new byte[1012]; ...

Can I get a byte[] from a BitmapImage in Silverlight?

I'm trying to pass some representation of an image back and forth between Silverlight and a WCF service. If possible I'd like to pass a System.Windows.Media.Imaging.BitmapImage, since that would mean the client doesn't have to do any conversion. However, at some point I need to store this image in a database, meaning the image represen...

How can I convert an Image to byte array in J2ME?

My requirement is like this. I need to read a file from the Mobile phone using a file connection, create a thumbnail of that image and post to the server. I am able to read the image using the FileConnection API, and also able to create the thumbnail. After creating the thumbnail, I am not able find a method to convert back that image t...

encoding/decoding string and a special character to byte array

Hi I had a requirement of encoding a 3 character string(always alphabets) into a 2 byte[] array of 2 integers. This was to be done to save space and performance reasons. Now the requirement has changed a bit. The String will be of variable length. It will either be of length 3 (as it is above) or will be of length 4 and will have 1 spe...

Comparing two ByteArrays C#

I have a test that uploads a bytearray (image - jpg) to our database (Sql Server FileStream) and then retrieves it through a HttpHandler. Next I compare the two. Now, they are almost the same except for the first four bytes... What's in those first four bytes? First byteArray : 255, 216, 255, 224, from here on they are the same Secon...

does java hava a function to convert string to byte array ?

is there any function in java that converts string to byte array ? ...

convert byte array to string without interpreting the bytes?

Hi I have a GSM date/time stamp from a PDU encoded SMS it is formatted as so \x90,\x21,\x51,\x91,\x40,\x33 format yy,mm,dd,hh,mm,ss I have read them from a binary file into a byte array. I want to convert them to a string but without doing any decoding I want to end up with a string that contains 902151914033. I then need to reverse ...

Java: How to "trim" a byte array?

So I have some code that reads a certain amount of bytes from a file and returns the resulting byte array (this is basically used for chunking up files to send over the network as (eventually) base64-encoded ascii text). It works fine, except that when the last chunk of the file is generated, it isnt a full chunk. Therefore, the resulti...

Flash Loader and ByteArray

I need to be able to load a jpeg/png image from disk and show it in flex and send it to a server as a base64 encoded string. But once the image file is loaded, in my flash.display.LoaderInfo object, the bytes property (type of ByteArray) contains more byte than the file content. Example: image file size: 3089 flash.display.LoaderInfo.b...

C# Convert byte array to string, using preamble or default encoding

Im trying to convert a byte array to a string. The byte array includes a preamble (if the used encoder had one of those), and you must specify the default encoding if no preamble is stored in the byte array. My code looks like this public static string ArrayToStringUsingPreambleOrDefaultEncoder(byte[] bytes, Encoding defaultEncoder, o...

ActionScript3 sign-extension with indexed access to ByteArray

In the following code: var bytes:ByteArray = new ByteArray(); var i:int = -1; var j:int; bytes[0] = i; // bytes[0] = -1 == 0xff j = bytes[0]; // j == 255; The int j ends up with value 255, rather than -1. I can't seem to find a document defining how indexed access to a ByteArray is supposed to be sign extended - can I reliably...

How to return a byte[] doing chunking using remoting over http in C#?

In .Net remoting over http, we return a byte[] back to the client by doing a SerilizationInfo.AddValue(SerializationInfoValueName, ((MemoryStream)writer.BaseStream).GetBuffer(), typeof(byte[])) call. However, sometimes the byte[] size gets too big and causes an OutOfMemory exception. The only remedy seems to be utilize some form of chu...

Android - Playing mp3 from byte[]

I have my mp3 in byte[] (downloaded from service) and I would like to play it on my device similar to how you play files: MediaPlayer mp = new MediaPlayer(); mp.setDataSource(PATH_TO_FILE); mp.prepare(); mp.start(); But I can't seem to find a way to do it... I wouldn't mind saving file to phone and than playing it, I am just hopi...

C# byte[] substring? (design)

I'm downloading some files asynchronously into a large byte array, and I have a callback that fires off periodically whenever some data is added to that array. If I want to give developers the ability to use the last chunk of data that was added to array, then... well how would I do that? In C++ I could give them a pointer to somewhere i...

How to efficiently set one bit at a time in an Erlang binary whithout going imperative?

As an exercise I am working on a parallel implementation of the Sieve of Eratosthenes. As part of that I am implementing a sequence of bitmaps, using one bit per number to save memory. Reading bits one at a time appear to work fine, but setting them is slow, especially when I use large binaries. getBit(Bin, N, Size)-> R=Size-N-1, ...

TCP Server and MemoryStreams/ByteArrays

I've got a TCP server written in C# that processes POST data sent to it. Currently it works fine unless a large amount of data (i.e. greater than 1GB) is sent to it then it runs out of memory (I store it all in memory as an array of bytes (with a intermediary of a List DTO)). For large files now I stream down to disk and then pass the fi...

Best way to read a large file into byte array in C#?

I have a web server which will read large binary files (several megs) into byte arrays. The server could be reading several files at the same time (different page requests) so I am looking for the most optimized way for doing this without taxing the CPU too much. Is the code below good enough? public byte[] FileToByteArray(string fileN...

Send ByteArray to JavaScript

How to send a jpg image as ByteArray from as3 to javescript? And how to convert ByteArray to image in javascript? ...

Passing Informaton for Files with Loader

I'm using Loader to get the image data out of a ByteArray. The problem is that I need to store that image data with a name (which is known beforehand) once it's passed to the complete handler. Since the operation is asynchronous, I can't be sure which image of multiple will finish loading first, so it seems I need to pass the information...

Determine color quality of image byte stream in sql

Does anyone know of a way to determine if a image stream is in color or black and white, I have thousands of images to process from sql server stored in a varbinary. Can one read the images header (if type of image is known - bitmaps) from byte offsets directly? IF so how can i do this in sql. ...