Is there any way to write content of Java InputStream to an OutputStream?

0 votes
If an InputStream in and an OutputStream out is given. Is there a way to write content from in to out?
Jul 6, 2018 in Java by Akrati
• 3,150 points
48 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

org.apache.commons.io.IOUtils from Apache has a method called copy(InputStream,OutputStream).which does exactly what you're looking for

InputStream in;
OutputStream out;
IOUtils.copy(in,out);
in.close();
out.close();
answered Jul 6, 2018 by sharth
• 3,310 points

Related Questions In Java

0 votes
1 answer

Is there any way to declare an array in-line?

You can probably refer this:  m(new String[]{"hi", "hello", ...READ MORE

answered Jul 10, 2018 in Java by Daisy
• 8,020 points
13 views
0 votes
1 answer

In Java, what is the best way to determine the size of an object?

Please check the below code to arrive ...READ MORE

answered Nov 21, 2018 in Java by Frankie
• 9,570 points
50 views
0 votes
1 answer

What is an efficient way to implement a singleton pattern in Java?

Use an enum: public enum Foo { ...READ MORE

answered Jul 6, 2018 in Java by Akrati
• 3,150 points
55 views
0 votes
1 answer

What is the easiest way to iterate through the characters of a string in Java?

The below code seems the easiest to ...READ MORE

answered Jul 13, 2018 in Java by scarlett
• 1,280 points
28 views
0 votes
2 answers

How do I read and convert an InputStream object to string type?

You can also use Java Standard Library ...READ MORE

answered Jul 17, 2018 in Java by Sushmita
• 6,820 points
1,513 views
0 votes
1 answer

How to read and write on an excel files?

Follow these steps: Write: public class User { ...READ MORE

answered May 15, 2018 in Java by Rishabh
• 3,520 points
142 views
0 votes
2 answers

Scanner is skipping nextLine() after using next() or nextFoo()?

use input.nextLine(); after your nextInt() function for example:- input.nextInt(); ...READ MORE

answered May 11 in Java by Sourav Dangi
443 views
0 votes
1 answer

Reading an InputStream & coverting it into a String in Java?

Use Apache commons IOUtils and copy the ...READ MORE

answered Oct 8, 2018 in Java by DataKing99
• 8,100 points
35 views
0 votes
1 answer

How to get the IP address of the machine using Java?

One approach is to use NetworkInterface.getNetworkInterfaces() to get all ...READ MORE

answered Jun 25, 2018 in Java by sharth
• 3,310 points
23 views
0 votes
1 answer

How to count the number of occurrences of an element in a List?

We can use the static frequency() method. int ...READ MORE

answered Aug 21, 2018 in Java by sharth
• 3,310 points
35 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.