Questions tagged [inputstream]

An abstract mechanism for reading a data stream in Java

An InputStream is an abstract mechanism for reading a data stream in Java. A stream is usually comprised of data obtained from a local file, or data being transmitted from a remote server over a network protocol such as HTTP or FTP.

An InputStream is abstract, and doesn't describe the type of data that is being read. Typically you would implement one of the subclasses instead, such as FileInputStream, which more appropriately describes the type of data being handled, and provides additional methods appropriate for that data type.

Streamed data is typically consumed as it is read. In other words, you read the data from the stream starting from the first byte and ending at the last byte. You are usually able to skip over bytes that you don't want to handle, but you can't typically go back to a previous position in the stream, unless you implement some kind of buffering mechanism. In general, you should treat all streamed data as being once-only, and thus you should manually retain any information that you wish to refer to later.

4382 questions
1
vote
0 answers

android firebase putStream(): E/StorageException: closed java.io.IOException: closed

I'm trying to upload a picture to firebase. If I load the picture from an InputStream to my app and upload it with putBytes(), it works, if I try to directly upload the picture with putStream(), I get an error message, that the stream is…
murkr
  • 634
  • 5
  • 27
1
vote
1 answer

Program to Copy data of one file into another file for 15 times

import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; public class JavaCopyFile { public static void main(String[] args)…
Naga Pavan
  • 13
  • 6
1
vote
0 answers

Premature end of file error. How to resolve? XML

I've been reading over this SAXParseException error for a while and trying to resolve it but to no success. [Fatal Error] schedule.xml:1:1: Premature end of file. org.xml.sax.SAXParseException; systemId: file:/U:/schedule.xml; lineNumber: 1;…
E.C
  • 45
  • 1
  • 7
1
vote
0 answers

Java S3 getObjectContent

I am trying to use this example from the AWS documentation to get a file from S3. The file I am trying to read from S3 is a binary file. I need the InputStream from s3object.getObjectContent() to work with it in another framework. If I am trying to…
Nico
  • 51
  • 1
  • 5
1
vote
1 answer

Showing inputstream file read progress with AsyncTask

I would like to show the progress of a file being read, and placed into an array list. In doing so, before the application presents the array-list in a list view to the user, I would like to show how much of the file has been read via an AsyncTask.…
TJF
  • 39
  • 1
  • 6
1
vote
3 answers

Single inputstream containing two files. I want to split those files

In java I'm having an inputstream (maybe sequenceinputstream) containing more than one file. I want to separate those files using java. Is there any solution available in java?
Roshan
  • 2,019
  • 8
  • 36
  • 56
1
vote
1 answer

create jar file with xml file inside using maven

So I've been trying to deploy a project as a jar and it needs to read a file this way: private static final String DEFAULT_PATH = "org/some/thing/cool/necesaryFile.xml"; public void readSomeFile() { InputStream is = null; try { …
Mokz
  • 124
  • 1
  • 16
1
vote
0 answers

How can I get my program to send a message out to the player alerting them if their opponent has finished inputting their move?

I am running a server that accepts two clients and pairs them against each other in a battle simulation. When one player inputs a command I want my server to tell the other player that they're being waited on. The problem is that my server is very…
Tre Zareck
  • 11
  • 2
1
vote
1 answer

Read content from InputStream in bitbucket api methods

I'm trying to read a file for a pre-receive hook with the bitbucket api. The point is, I need to check some concrete file and content stuff in order to aprove or reject the commit. You can see the code…
dcalap
  • 1,048
  • 2
  • 13
  • 37
1
vote
1 answer

Is it possible to create more than 1 consumers on InputStream and OutputStream?

I am implementing a Java project using client-server architecture. My client goes into an infinite loop when connected via socket. EDIT1: I have changed my client and server programs to minimal, complete and verifiable codes. The issue arises due to…
1
vote
1 answer

Read a binary file in java up to a specific "%%EOF" marker?

I need to read a binary file in java and split it up (its actually a binary file containing many pdf files, with a single line "metadata" before each). Each pdf item from the binary file ends with a "%%EOF" marker. My first attempt, I read the file…
vikingsteve
  • 38,481
  • 23
  • 112
  • 156
1
vote
1 answer

Issue with http connection on samsung device but not on other device

I have an android app which works perfectly on my phone (Huawei Mate 10 Pro) but when I try to run it on my tablet (Samsung Galaxy Tab S2) I get a java.io.FileNotFoundException when the app tries to access the input stream. (I get the exception at…
1
vote
0 answers

Listen to socket on a specific port number as a client

I want to know how to listen to a specific port when the application is client for example; IP:127.0.0.1 and port number 12345. There is a windows application which can listen to incoming data from server in every 2 minutes but Inputstrem doesn't…
Mohsen Hatami
  • 317
  • 3
  • 14
1
vote
4 answers

Trying to read from a URL(in Java) produces gibberish on certain occaisions

I'm trying to read from a URL, and then print the result. BufferedReader in = new BufferedReader( new InputStreamReader(new URL("http://somesite.com/").openStream(), "UTF-8")); String s = ""; while ((s=in.readLine())!=null)…
John Saetz
  • 11
  • 3
1
vote
2 answers

NullPointerException when trying to read info from an url using HttpURLConnection

I'm trying to read some information from an url using HttpURLConnection, however, when I try to run it I get: java.lang.RuntimeException: Unable to start activity ComponentInfo{...}: java.lang.NullPointerException: println needs a …
1 2 3
99
100