Questions tagged [java-io]

The java.io package provides blocking input and output through data streams, serialization, and the file system.

Most applications need to process some input and produce some output based on that input. The purpose of the Java IO package (java.io) is to make that possible in Java.

The java.io package provides blocking input and output through data streams, serialization and the file system.

1753 questions
3
votes
6 answers

isDirectory() returns true for a file

In my java program I copy a file and delete the new file. In my method removeFile() I check if it is a directory: String fileName = "G:/1310628353186Examples.csv"; File f = new File(fileName); if (f.isDirectory()) { System.out.println( "'" +…
Skyline
  • 63
  • 1
  • 8
3
votes
1 answer

Sending image as text in java

Is it possible to read image as text and send it over network? Is yes, then how can we do this?
Ankit
  • 3,083
  • 7
  • 35
  • 59
3
votes
2 answers

Why is it said: CharacterStream classes are used to perform the input/output for the 16-bit Unicode characters?

When an I/O stream manages 8-bit bytes of raw binary data, it is called a byte stream. And, when the I/O stream manages 16-bit Unicode characters, it is called a character stream. Byte stream is clear. It uses 8-bit bytes. So if I were to write a…
Stefan
  • 969
  • 6
  • 9
3
votes
1 answer

Read binary stream containing unsigned numbers

I want to read binary file containing 32-bit unsigned integers and 8-bit unsigned integers. I already know DataInputStream but its method readInt returns signed integers and there is no method for reading unsigned ints (there are such methods for…
jiwopene
  • 3,077
  • 17
  • 30
3
votes
2 answers

Flutter path_provider error on Android, while on iOS works perfectly

I'm using the [flutter_pdfview][1] package in my Flutter app, in order to present PDF files downloaded from the internet. I use the path_provider package to download the file and store it in the devicee. Both packages works perfectly fine when…
F.SO7
  • 695
  • 1
  • 13
  • 37
3
votes
4 answers

Why is java.io.Reader#skip implemented the way that it is?

I'm still learning object-oriented programming in Java. I was looking at the Java implementation of java.io.Reader.skip and I'm wondering why exactly it's implemented the way that it is. In particular I have questions about these things that I have…
user766413
  • 121
  • 1
  • 6
3
votes
1 answer

how to interact with system cmd line using java code

I'm trying to create a Java code that creates a nifi customized processor ! so in order to do that I need to use windows cmd windows and launch mvn archetype:generate then choose the modele nifi by typing nifi then choose the project by typing1 the…
maryem neyli
  • 467
  • 3
  • 20
3
votes
1 answer

Why does apache http client about 2 time slower then URL.openConnection in java?

Consider this code: package com.zip; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpHead; import…
Cherry
  • 31,309
  • 66
  • 224
  • 364
3
votes
2 answers

Searching for a String in a .txt file and getting the row and column number in Java

I am currently stuck with a problem. I am supposed to write a programm that is able to search for a string in a .txt file given as argument. The programm must return the row and the column of the found string. I am struggling to find a way to…
3
votes
3 answers

stitch images together in java

I'm trying to stitch some images together using java. I have a bunch of images I'd like to stitch together and they are all the same dimensions so it's really just a question of lining them up next to each other I suppose. I have it working but…
JPC
  • 8,096
  • 22
  • 77
  • 110
3
votes
2 answers

Apache POI - java.lang.NoClassDefFoundError: org/apache/commons/compress/utils/InputStreamStatistics

I'm trying to read a word document (.docx) using Apache POI and it gives me this error... Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apache/commons/compress/utils/InputStreamStatistics at…
3
votes
2 answers

Read file attibutes for all files in the tree using as few IO operation as possible

I have a lot of small files on a NFS drive (Amazon EFS in my case). Files are provided over HTTP protocol, very similar to a classical Web-Server it does. As I need to validate the last modification of the file, it takes at least a single I/O per…
30thh
  • 10,861
  • 6
  • 32
  • 42
3
votes
1 answer

Problem accessing file from jar file in Java

I have a jar called App.jar and it's structure is as follows App.jar | | |---xyzfolder | | | |--config | | | |--config.properties | | |---com (contains classes) …
Ankit
  • 2,753
  • 1
  • 19
  • 26
3
votes
1 answer

Can I close/reopen InputStream to mimic mark/reset for input streams that do not support mark?

I'm trying to read java.io.InputStream multiple times starting from the top of the stream. Obviously for streams that return true to markSupported() I can try and use mark(availableBytes) and then reset() to read stream again from the top. Most of…
parxier
  • 3,811
  • 5
  • 42
  • 54
3
votes
2 answers

Why does my stream copying procedure steadily degrades in performance

This code works slower and slower during copying large files. Am I doing something wrong? InputStream ms2 = new BufferedInputStream(new FileInputStream("/home/fedd/Videos/homevid.mp4")); OutputStream fos2 = new BufferedOutputStream(new…
fedd
  • 880
  • 12
  • 39