inputstream

Read and parse line in C/C++; put tokens in an array or vector or similar structure

Hello everyone, I have to submit code to one of the problems in ACM IPC and, as you may know, the time counts a lot. So, I have to read efficiently an input like this: The first line will contain the sequence of integer values associated and the second line will contain the sequence of integer values associated with another sequence. E...

What 0 returned by InputStream.read() means? How to handle this?

What 0 (number of bytes read) returned by InputStream.read means? How to handle this situation? Update: I mean read(byte[] b) or read(byte[] b, int off, int len) methods which return number of bytes read. ...

J2ME/Java: Referencing StringBuffer through Threads

This question might be long, but I want to provide much information. Overview: I'm creating a Stock Quotes Ticker app for Blackberry. But I'm having problems with my StringBuffer that contains an individual Stock information. Process: My app connects to our server via SocketConnection. The server sends out a formatted set of strings th...

not waiting for keyboard input (overloaded input stream operator) in C++

Just a quick question. I have developed the following code: #pragma once #include <iostream> using namespace std; class Percent { public: friend bool operator ==(const Percent& first, const Percent& second); friend bool operator <(const Percent& first, const Perc...

Writing data to InputStream of grep program invoked in java

I'm trying to process data obtained from a run of diff to an instance of GNU grep in a java program. I've managed to get the output of diff using the Process object's outputStream, but I'm currently having programs sending this data to the standard input of grep (through another Process object created in Java). Running Grep with the inpu...

Reading HTML data from database is slow? Need a better approach?

We have a table in mysql of 18GB which has a column "html_view" which stores HTML source data, which we are displaying on the page, but now its taking too much time to fetch html data from "html_view" column, which making the page load slow. We want an approach which can simplify our existing structure to load the html data faster from ...

Read multiple lines from InputStreamReader (JAVA)

I have an InputStreamReader object. I want to read multiple lines into a buffer/array using one function call (without crating a mass of string objects). Is there a simple way to do so? ...

Java process inputstream in thread

Hi! I develop an Eclipse plugin and I have a problem My code is the following one: String run_pelda = "cmd.exe /C pelda.exe"; Runtime pelda_rt = Runtime.getRuntime(); Process pelda_proc = javacheckgen_rt.exec(run_pelda); And after I would like to read the inputstream: InputStream toolstr = tool_proc.getInputStream(); InputStreamRea...

Resetting the InputStream of a Java Socket after reaching EOS.

I'm attempting to connect two separate applications via a TCP/IP socket. In this case neither of the applications is running as a "client" of the other, it would be easier to describe them as two separate servers who need to communicate with each other. To receive the data I'm using the InputStream.Read() function and once it receives a...

File path/name from InputStream

How to obtain File Path/Name from an InputStream in Java ? ...

What's the correct way to read an inputStream into a node property in JCR 2?

In JCR 1 you could do: final InputStream in = zip.getInputStream(zip.getEntry(zipEntryName)); node.setProperty(JcrConstants.JCR_CONTENT, in); But that's deprecated in JCR 2 as detailed at http://www.day.com/maven/jsr170/javadocs/jcr-2.0/javax/jcr/Node.html#setProperty%28java.lang.String,%20java.io.InputStream%29 That says I should be...

How do I/O operations block?

I am specifically referring to InputStream (Java SE) and its implementations. How is blocking performed? I'm a little worried that they use a "busy-waiting" mechanism, as it would produce a lot of overhead. I believe they do it another way, but I'm just asking to be certain. ...

java: speed up reading foreign characters

My current code needs to read foreign characters from the web, currently my solution works but it is very slow, since it read char by char using InputStreamReader. Is there anyway to speed it up and also get the job done? // Pull content stream from response HttpEntity entity = response.getEntity(); InputStream inputStre...

Loading from JAR as an InputStream?

Is there a ClassLoader implementation I can use to load classes from an InputStream? I'm trying to load a JAR for which I have an InputStream into a new ClassLoader. ...

How to read in a double from a file in c++

How do you read in a double from a file in C++? For ints I know you can use the getline() and then atoi, but I am not finding an array to double function. What is available for reading in doubles, or converting a char array to a double? ...

reading a set count of characters from the console input stream

I'm trying to make something like a textbox for a console application, how to limit the Console.In to only read a defined count of characters from user inputs ? EDIT I can't go the Readkey() loop -way, i still need to interact with that box, like using the arrow keys to navigate left an right, Del or Backspace to edit the input and so...

Is there a nice, safe, quick way to write an InputStream to a File in Scala?

Specifically, I'm saving a file upload to local file in a Lift web app. ...

Reading HttpURLConnection InputStream - manual buffer or BufferedInputStream?

When reading the InputStream of an HttpURLConnection, is there any reason to use one of the following over the other? I've seen both used in examples. Manual Buffer: while ((length = inputStream.read(buffer)) > 0) { os.write(buf, 0, ret); } BufferedInputStream is = http.getInputStream(); bis = new BufferedInputStream(is); ByteAr...

getResourceAsStream() is always returning null

I have the following structure in a Java Web Application: TheProject -- [Web Pages] -- -- [WEB-INF] -- -- -- abc.txt -- -- index.jsp -- [Source Packages] -- -- [wservices] -- -- -- WS.java In WS.java, I am using the following code in a Web Method: InputStream fstream = this.getClass().getResourceAsStream("abc.txt"); B...

Java: Is my input.readObject() getting truncated on either write or read?

I'm building a system to exchange encoded messages, call it bank and client. The first messages that I need to exchange are long Strings. They appear to be truncated either in the write or read, but I'm not sure how to figure out where. Read: client = new Socket(InetAddress.getByName(bankServer), 12345); displayMessage("Connected to:...