Questions tagged [ioutils]

IOUtils is a [java] class in the IO subproject of Apache Commons. The class provides general IO stream manipulation utilities. Use this tag for questions about the IOUtils class.

org.apache.commons.io.IOUtils is a java class that provides general IO stream manipulation utilities including reading, writing and copying files. The class is part of the Apache Commons IO project. Apache Commons IO is a library of utilities to assist with developing IO functionality. It is a subproject of Apache Commons which is an Apache project focused on all aspects of reusable Java components.

30 questions
0
votes
2 answers

How to read the pdf content from response and write it to another new pdf file

%PDF-1.4 %���� 1 0 obj << /Type /Catalog /Pages 9 0 R /Outlines 8 0 R /Names 6 0 R i am trying to read above pdf content response from rest end point in java class and trying to write it to another file but the file is getting corrupted and I could…
0
votes
1 answer

IOUtils.ToByteArray(InputStream) is thread safe?

Can using IOUtils.ToByteArray leads to concurrency problems? private byte[] saveLetterContent(InputStream input) { ... byte[] letterContent = IOUtils.toByteArray(input); ... } I mean is it possible that letterContent in this method change…
elahe
  • 11
0
votes
0 answers

Chunked Encoding vs writing on HttpServletResponse outputStream?

What benefit does chunked encoding provide over directly writing on the HttpServletResponse output stream in small chunks? So doing something like the code shown below where the full file content is not being buffered in the app-memory vs sending…
ab m
  • 422
  • 3
  • 17
0
votes
0 answers

How to reconstruct html file at consumer side in kafka?

If i feed html files in the form of Array[Byte] at producer side in kafka then how to reconstruct html file at consumer side in kafka ? This is how i am converting html files into Array[Byte] def getByteArray(fileName: String): Array[Byte] = { …
0
votes
1 answer

why common-io tool IOUtils.toByteArray is not same?

Why aren't the results the same when using commons.io.IOUtils to get byte[]? The toByteArray method params are Inputstream and Reader. String file = "c:/c.pdf"; try (InputStream is = new FileInputStream(file)) { byte[] result =…
wangxl
  • 161
  • 1
  • 1
  • 5
0
votes
2 answers

IOUtils.toByteArray is returning empty byte array

I am new to Java development so apologies in advance if I am asking something stupid. I am trying to retrieve an image and it's thumbnail from sql database. I get data from ResultSet in BinaryStream format and then convert it to byte[]. For…
Umair Aamir
  • 1,624
  • 16
  • 26
0
votes
1 answer

Compress InputStream with GZIPOutputStream into ByteArray

I have a method that takes an InputStream as a parameter and I'm trying to compress the input stream using GZIPOutputStream and then return a compressed byte array. My code looks like this: public static byte[] compress(final InputStream…
0
votes
0 answers

Replace file content certain line data which contains special characters through Java

I have found many ways to replace particular file line content using Java and it worked fine up to certain data. When line contains special characters, IOUtils.write() method fails to replace those content. I'm using latest Java 1.8. Same method…
Jitesh Sojitra
  • 3,655
  • 7
  • 27
  • 46
-1
votes
1 answer

In Java, how to write to a file from input stream? I am getting IOException: Pipe closed

I created a file and writing an input stream to it but I am getting this exception with just this info IOException: Pipe closed. Here is my code: File outputFile = new File(filePath); try (OutputStream outputStream = new…
Atihska
  • 4,803
  • 10
  • 56
  • 98
-1
votes
1 answer

Java Get back InputStream from String Converted by Apache IOUtils

I am using library Sharepoint-Java-API to download Files from Sharepoint. I am able to download file but got as String format which is converted using org.apache.commons.io.IOUtils as public static String get(Pair token, String url)…
Shantaram Tupe
  • 1,646
  • 3
  • 16
  • 42
-1
votes
1 answer

InputStream Size unable to get in java when more than 1 gb. needs more buffer exception coming. how to resolve?

I am using inputstream to read data and byteArray to get size. I am getting outOfMemory issue need new buffer in bytearray as file size is 1.5 gb. i have checked in stackoverflow and googled lots of places. i couldn't find the solution to get the…
Learner
  • 43
  • 1
  • 1
  • 8
-2
votes
1 answer

Issues with io/ioutil

Good afternoon, I'm trying to grab processes id's with my limited knowledge on golang and the below is what I've come up with: package main import ( "fmt" "io/ioutil" "log" "os" "os/exec" "strings" ) func main() { …
Lewis
  • 3
  • 2
-2
votes
1 answer

hot to convert ioutil.ReadAll into json in golang

I'm trying to convert a response into json in golang. func receive(w http.ResponseWriter, r *http.Request) { reqBody, _ := ioutil.ReadAll(r.Body) json.NewEncoder(w).Encode(string(reqBody)) println(string(reqBody)) func handleR() { …
Fabian
  • 11
  • 3
-2
votes
1 answer

Creating files from ByteArrayOutputStream

I am trying to create separate files from ByteArrayOutputStream (Here byteOut is my ByteOutputStream). The following code does the job final InputStream targetStream = new ByteArrayInputStream(byteOut.toByteArray()); final File…
Bhoomi
  • 17
  • 4
-3
votes
1 answer

input string from a file and compare the input string

I want to input strings from a file and check whether each of the string match a given string, but I couldn't make it. Thanks in advance for helping. My code is as following: import java.util.*; import java.io.*; import…
Jess
  • 71
  • 3
  • 10
1
2