🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › io › InputStream.html
InputStream (Java Platform SE 8 )
March 16, 2026 - Tests if this input stream supports the mark and reset methods. Whether or not mark and reset are supported is an invariant property of a particular input stream instance. The markSupported method of InputStream returns false. ... Java™ Platform Standard Ed.
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › io › ByteArrayInputStream.html
ByteArrayInputStream (Java Platform SE 8 )
March 16, 2026 - java.io.InputStream · java.io.ByteArrayInputStream · All Implemented Interfaces: Closeable, AutoCloseable · public class ByteArrayInputStream extends InputStream · A ByteArrayInputStream contains an internal buffer that contains bytes that may be read from the stream.
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-io-input-output-in-java-with-examples
Input/Output in Java with Examples - GeeksforGeeks
Before exploring various input ... that Java has provided: ... System.in: This is the standard input stream that is used to read characters from the keyboard or any other standard input device....
Published   December 10, 2025
🌐
Core Java
corejava4all.wordpress.com › tag › inputstream
InputStream – Core Java
Streams in Java represent an ordered sequence of Data. Good thing is, Streams abstract away the details of underlying source/destination. It could be a memory, or disk-based storage or network.
🌐
DaniWeb
daniweb.com › programming › software-development › threads › 192297 › help-with-a-inputstream
java - Help with a inputstream... [SOLVED] | DaniWeb
May 16, 2009 - InputStream, as the Java API doc makes very clear, is an abstract class; it's definition is incomplete and you cannot instantiate it with new. It's purpose in life is to define a standard set of operations that any byte-oriented input stream should implement.
🌐
Baeldung
baeldung.com › home › java › java io › java – convert file to inputstream
Java - Convert File to InputStream | Baeldung
January 5, 2024 - We can use the IO package of Java to convert a File to different InputStreams.
🌐
Oracle
docs.oracle.com › en › java › javase › 11 › docs › api › java.base › java › io › InputStream.html
InputStream (Java SE 11 & JDK 11 )
January 20, 2026 - java.io.InputStream · All Implemented Interfaces: Closeable, AutoCloseable · Direct Known Subclasses: AudioInputStream, ByteArrayInputStream, FileInputStream, FilterInputStream, ObjectInputStream, PipedInputStream, SequenceInputStream, StringBufferInputStream ·
🌐
Medium
medium.com › @pratik.941 › introduction-to-java-i-o-streams-3485de108ed1
Introduction to Java I/O Streams. Java I/O (Input and Output) streams are… | by Pratik T | Medium
July 28, 2024 - Byte streams read and write data in bytes (8 bits). They are used for handling binary data such as images, audio files, etc. ... 1. InputStream: The superclass for all byte input streams.
Find elsewhere
🌐
Reddit
reddit.com › r/learnprogramming › [java] confusion regarding definition of "inputstream" acting as a parameter
r/learnprogramming on Reddit: [Java] Confusion regarding definition of "InputStream" acting as a parameter
January 1, 2023 -

Currently in my first programming course, and in the topic of objects and classes in Java, we've been given a task of creating a class that registers user's various inputs (Strings of texts, integers and decimals, e.t.c. Essentially creating a less generalized, more specified Scanner-class.), of which the instructions request the building of two constructors: one without parameters and one with so-called InputStream as its parameter; a term first introduced in this task, and which I assume through documentation is a specific class that is included in a java.io-package already included in most compilers and editors.

This definition comes in conflict, however, as while the official documentation seems to view InputStream as a class, the task I've been given describes it (In the context of this task of making a registering input-class.) of making InputStream as part of a constructor's parameter as a "...a data type to System.in.". This would make me presume that it is meant to be used in similar fashion of how we have learned of how basic parameters utilize primitive data-types (String, int, double, e.t.c.) along with its associated variable names, where such constructor for a class with the name "Register" would be in fashion of:

import java.util.Scanner;

public class Register {

	private Scanner input = new Scanner(System.in);

	//Constructor #1
	public Register(){

	}

	//Constructor #2
	public Register(InputStream System.in){

	}

This obviously doesn't work due to what I assume the function of InputStream acting as a class takes precedent than having it act as a data type (Can the name of classes even be designated as a data type? I haven't been able to find confirmation of it.). The term has been quite confusing along with the context of other input-related terminology of Scanner-class and System.in (The latter apparently is described as being an InputStream itself?), so I would much appreciate if someone could clarify what the task refers to when they claim that InputStream can act as a parameter of a constructor.

Top answer
1 of 2
1
An input stream, as the docs note, is just a thing that represents "an input stream of bytes". So an input stream is an ordered sequence of bytes. Who knows where these bytes come from? Maybe it comes from a file, or from a network, or maybe it's randomly generated by a random number generator. But one common place to get a "stream of bytes" is from standard in . If you want to represent standard in's input as an InputStream, you can do: InputStream stdin = System.in; In contrast, if you wanted to get the data in a file, you could do something like: InputStream bytesInAFileStream = new FileInputStream(new File("myAwesomeFile.txt")); Anyway, for you, it doesn't much matter how this input stream comes into existence. You're just writing a constructor that uses an input stream. So you're not responsible for making the input stream; you'll be given one, and then use it in your own class. This isn't unusual -- you mentioned Scanners and indeed, the Scanner class has a constructor that takes in an input stream -- https://docs.oracle.com/javase/7/docs/api/java/util/Scanner.html#Scanner(java.io.InputStream) : InputStream stdin = System.in; Scanner scanner = new Scanner(stdin); String firstLineOfInput = scanner.nextLine(); Your class will likely behave similarly to how Java's Scanner class is used.
2 of 2
1
It seems like you're confused about classes and data types. InputStream is a class, and classes are also data types. System.in is a reference to a specific instance of an InputStream. You absolutely can pass an InputStream into a constructor in the way you've described. The issue with your code is that parameters have a type (InputStream) and a name (System.in) but System.in is not a valid variable name.
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › io › DataInputStream.html
DataInputStream (Java Platform SE 8 )
March 16, 2026 - A data input stream lets an application read primitive Java data types from an underlying input stream in a machine-independent way. An application uses a data output stream to write data that can later be read by a data input stream. DataInputStream is not necessarily safe for multithreaded access.
🌐
Programiz
programiz.com › java-programming › io-streams
Java I/O Streams
Java InputStream Class · Java OutputStream Class · Java OutputStreamWriter Class · Java InputStreamReader Class · Java ObjectInputStream Class · Java ByteArrayInputStream Class · In Java, streams are the sequence of data that are read from the source and written to the destination.
🌐
Medium
medium.com › @dilipkumargurijala18 › mastering-file-i-o-in-java-working-with-inputstream-and-outputstream-6c6a968d0d72
Mastering File I/O in Java: Working with InputStream and OutputStream. | by DIlip Kumar Gurijala | Medium
January 26, 2025 - An InputStream in Java is a part of the java.io package and represents a stream of data for reading input, typically from a source such as a file, network socket, or other input devices.
🌐
Bluestep
clientcare.bluestep.net › jslib › docs › B › classes › Java.Java.IO.InputStream.html
InputStream | Bluestep JS Documentation
Defined in dev/github/bluestep-systems/web/build/tsdoc/combined/jslib/types/B/Java.d.ts:697 ... Skips over and discards n bytes of data from this input stream. ... Reads all bytes from this input stream and writes the bytes to the given output stream in the order that they are read. ... Returns a new InputStream that reads no bytes.
🌐
Mkyong
mkyong.com › home › java › how to convert inputstream to file in java
How to convert InputStream to File in Java - Mkyong.com
December 27, 2020 - And we use FileOutputStream to copy the InputStream into a File, and save it somewhere. ... package com.mkyong.io.howto; import java.io.*; import java.net.URI; public class InputStreamToFile1 { /** * The default buffer size */ public static final int DEFAULT_BUFFER_SIZE = 8192; public static void main(String[] args) throws IOException { URI u = URI.create("https://www.google.com/"); try (InputStream inputStream = u.toURL().openStream()) { File file = new File("c:\\test\\google.txt"); copyInputStreamToFile(inputStream, file); } } private static void copyInputStreamToFile(InputStream inputStream, File file) throws IOException { // append = false try (FileOutputStream outputStream = new FileOutputStream(file, false)) { int read; byte[] bytes = new byte[DEFAULT_BUFFER_SIZE]; while ((read = inputStream.read(bytes)) != -1) { outputStream.write(bytes, 0, read); } } } }
🌐
o7planning
o7planning.org › 13527 › java-inputstream
Java InputStream Tutorial with Examples | o7planning.org
InputStream is a class in java.io package, which is a base class representing a stream of bytes, obtained when reading a certain data source, such as file.
🌐
GeeksforGeeks
geeksforgeeks.org › java › difference-between-inputstream-and-outputstream-in-java
Difference Between InputStream and OutputStream in Java - GeeksforGeeks
January 28, 2021 - Thus, InputStream read data from source one item at a time. 1.2 OutputStream: OutputStream is an abstract class of Byte Stream that describes stream output and it is used for writing data to a file, image, audio, etc. Thus, OutputStream writes data to the destination one at a time. In this Program, the file gfg.txt consist of “GEEKSFORGEEKS”. Note: In the file is saved in the same location where java Program is saved then follow the below program.
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-io-inputstream-class-in-java
Java.io.InputStream Class in Java - GeeksforGeeks
March 28, 2024 - Java InputStream class is the superclass of all the io classes i.e. representing an input stream of bytes. It represents an input stream of bytes. Applications that are defining a subclass of the Java InputStream class must provide a method, ...
🌐
Scaler
scaler.com › home › topics › input stream in java
Input Stream in Java - Scaler Topics
October 17, 2022 - It is used for reading data in bytes from files and the class used is java.io. It extends the abstract class of the input stream called “InputStream”.To create and use the file input stream, we first need to import the package, ...
🌐
Baeldung
baeldung.com › home › java › java streams › convert inputstream to stream in java
Convert InputStream to Stream in Java | Baeldung
May 12, 2024 - In the provided code block, we create a byte array named bytes to hold the UTF-8 encoded representation of the provided text lines. Then, we use the ByteArrayInputStream(bytes) to create an InputStream named inputStream from this byte array.
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api
Java Platform SE 8
March 16, 2026 - JavaScript is disabled on your browser · Frame Alert · This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. Link to Non-frame version