inputstream

Process InputStream

Hello, How can I "modify" an InputStream? I have a file as input, I would like to modify some variable and forward a new InputStream. For example, the initial InputStream contains Hello ${var}. Then I want to "modify" this InputStream with var = "world", resulting an InputStream Hello world. What's the best practice to do this? Thanks...

Socket not closing serverside when calling socket.close() in client JAVA

Hello, I'm having problems with sockets in java. I have a ServerSocket that is listening with accept() and spawns threads for each client-request. Communication between clients and the server works fine. I am using an inputstream to read data from clients in the serverthreads, like: inputStream = mySocket.getInputStream(); bytes = inpu...

Java Non-blocking Read

Hello, I'm trying to read in from two different input streams (stdin and stderr of a child application) and print them in one combine frame. I've never done this before, and am wondering about best practices. I can spawn two threads and let them both block on the input stream. Is there a better way? Thanks! ...

Reading streams from java Runtime.exec

I have the following snippet of code: Process proc = runtime.exec(command); errorGobbler = new ErrorStreamGobbler(proc.getErrorStream(), logErrors, mdcMap); outputGobbler = new OutputStreamGobbler(proc.getInputStream(), mdcMap); executor.execute(errorGobbler); executor.execute(outputGobbler); processExitCode ...

Is Java's EOFException exceptional?

It seems dirty to use an exception to indicate the end of a file has been reached. Every file we read has an end, so it doesn't seem exceptional or unexpected. Furthermore, I don't like using an exception for the non-exceptional flow of my program. I'm talking about using java.io.EOFException to signal the end of a data input stream: I...

Need Help Reading Data From Inputstream

Hi Guys, I have a robot and a GUI application running on a GUI. I have a while loop on the robot side that is constantly sending data to the GUI. Before i send a value, i send first a value which the GUI will use to determine how many consecutive values it must read afterwards for instance i send something like; dataout.writeInt(2); d...

Need Help Again Reading Data From Inputstream

Hi Guys, Yesterday i posted a question about a problem i had concerning inputstream reading and i was helped. I find myself in similar situation but this time i know that I am doing the right thing but yet it is not working for me. I am reading from an inputstream but i get different value. No matter how i change the data i send i get...

Resources.getSystem().openRawResource(random.txt) returns Resource$NotFoundException

Building on 1.6 SDK4 InputStream is = Resources.getSystem().openRawResource(R.raw.vortexrules); This line is causing me no end of trouble... My R.java shows: public static final class raw { public static final int vortexrules=0x7f040000; which tells me that the compiler is recognizing the text file and the folder and setting t...

IOException in Android application

I have just started with Android development, and facing one issue in the android application. When application tries to read the data from file (raw resources), it throws IOException on readLine() function. code is as below: final Resources resources = m_ApplicationContext.getResources(); InputStream inputStream = resources.openRawRes...

Import Textfile and read line by line in Java

Hey guys, I was wondering how one would go about importing a text file. I want to import a file and then read it line by line. thanks! ...

Parse MMS Parts Using InputStream from WAP Server

After you attach an inputstream to am MMS message on a WAP server, does anyone have a suggestible Java api to parse the message? Someone may recommend the WMA of JavaMe, but JavaME is not the Java implementation on Android. I have tried using various .jar apis from sourceforge but none of them compile properly when added to the build pa...

servlet: convert an ServletInputStream into a FileInputStream

Hello, i'm writing a servlet that receives a xml file, gives it to another class and gives a html file with some comments back to the client. I'm getting the input-xml with something like: input = request.getInputStream(); but this input is a ServletInputStream and the other class(for the comments) needs a FileInputStream. If i give...

Servlet: cut upload header from the servletinputstream

Hello, I'm writing a servlet that receives an xml file from the client and works with it. My problem is, that in the servletinputstream (which i get with: request.getInputStream()) is some upload information at the beginning and at the end: -----------------------------186292285129788 Content-Disposition: form-data; name="myFile"; fil...

Help reading JSON from HttpContext.InputStream

I have created a HttpModule to capture requests for auditing purposes. For Ajax requests to a web method I would like to also log the JSON data associated with the request. E.g Request POST /MyPage.aspx/AddRecord HTTP/1.1 x-requested-with: XMLHttpRequest Accept-Language: en-gb Referer: http://fiddlerlocal:5000/AddRecord.aspx ...

Convert InputStream(Image) to ByteArrayInputStream

Not sure about how I am supposed to do this. Any help would be appreciated ...

C++ input string contain ASCII 26(Substitute) character. How to get rid of it ?

Here's my code. Purpose is to input a Vector of Student class, contain name and homework grades. istream& input(istream& is, student& s){ is.clear(); cout << "Enter student name: "; getline(is,s.name); grade(is,s.homework); return is; } istream& grade(istream& is, vector<double>& homework){ if(is){ homew...

How do I move zip file to blob column in Java?

I have a Java program that creates a number of xml file and then zips them up and saves them to the file system. Later in the program I want to put that same zip file into a blob column of my oracle database. Problem is I'm not sure how to do that. I don't need to read it or do anything with the data, just move it to the database for p...

copy a stream via byte[]

Hiho, i have to copy an inputstream. And after a bit of searching in the net, i tried this with the help of a bytearray. My code looks like this("is" is the inputstream): ByteArrayOutputStream bos = new ByteArrayOutputStream(); while (is.read() != -1) { bos.write(is.read()); } byte[] ba = bos.toByteArray(); ...

How do I read multiple ZipEntries through a single InputStream

Hi, I have to pass an InputStream as a parameter to a 3rd party library, which will read the complete contents from the InputStream and do its job. My problem is, some of my files are Zip files - with more than one ZipEntry. From what I understand, one can read one zipEntry at a time and then do a zipInputStream.getNextEntry() and the...

How to timeout a read on Java Socket?

I'm trying to read items from a socket and I notice that if there is nothing on the stream of the socket it will stay at the read and back up my application. I wanted to know if there was a way to set a read timeout or terminate the connection after a certain amount of time of nothing in the socket. ...