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
5
votes
1 answer

Creating a reflink with Java

java.nio.Files.createSymbolicLink is used to create a symbolic link. Can I create a reflink via the SDK (akin to cp --reflink=[WHEN]), or do I need to exec out to the underlying OS?
Synesso
  • 37,610
  • 35
  • 136
  • 207
5
votes
2 answers

Different behaviour for Path.toFile() and new File(pathString)

I have mounted a network drive (samba server) in Windows. I have a file in that drive that I wanted to read in a Java program. Before I was trying to read the file using: Paths.get(basePath, fileName).toFile() But it was failing with error that…
ata
  • 8,853
  • 8
  • 42
  • 68
5
votes
6 answers

How can i read the same file two times in Java?

I want to counter the lines of the file and in the second pass i want to take every single line and manipulating it. It doesn't have a compilation error but it can't go inside the second while ((line = br.readLine()) != null) . Is there a different…
Damis Berzovitis
  • 205
  • 1
  • 3
  • 11
5
votes
2 answers

Can't fetch from private repository with EGit

I am trying to synchronise my eclipse java project with my private git repository using EGit plug-in but I'm being unsuccessful. I have configured the remote origin as: URI: git@github.com:username/project.git Host: github.com Repository path:…
Maslor
  • 1,821
  • 3
  • 20
  • 44
5
votes
5 answers

Windows temporary file in Java

How to create a file in Windows that would have attributes FILE_ATTRIBUTE_TEMPORARY and FILE_FLAG_DELETE_ON_CLOSE set using Java? I do want my file to be just in-memory file. To precise: delete-on-exit mechanism does not satisfy me, because I want…
Przemysław Różycki
  • 809
  • 2
  • 10
  • 21
5
votes
3 answers

Shouldn't ObjectInputStream extend FilterInputStream?

The block quotes are from the Java Docs - A FilterInputStream contains some other input stream, which it uses as its basic source of data, possibly transforming the data along the way or providing additional functionality. A…
Vaibhav Bajpai
  • 16,374
  • 13
  • 54
  • 85
5
votes
1 answer

Apache hive error Merging of credentials not supported in this version of hadoop

I am using hadoop 1.2.1, hbase 0.94.14 and hive 1.0.0. There are three datanodes in my clsuter and three regionservers also. I have to import some data from hbase to hive. I have configured hive successfully but when I ran a command to count no. of…
Hafiz Muhammad Shafiq
  • 8,168
  • 12
  • 63
  • 121
5
votes
2 answers

Which of Files.readAllLines or Files.lines method is faster for file reading?

I have a file reader, which returns the lines of a file as an Object[]. I am using the lines method. Would it be faster to use readAllLines? I do not use the stream for anything else, but I want currentBookData to be a String[] or Object[]. package…
CaffeineToCode
  • 830
  • 3
  • 13
  • 25
5
votes
1 answer

OutputStreamWriter internal buffer size

I want to create an unbuffered OutputStreamWriter. The docs (Java 7) say The resulting bytes are accumulated in a buffer before being written to the underlying output stream. The size of this buffer may be specified, but by default it is large…
leonbloy
  • 73,180
  • 20
  • 142
  • 190
5
votes
1 answer

RandomAccessFile Vs NIO Channel

I am trying to understand the following behavior. My older code, String path = "C:/temp/sample.txt"; String mode= "rw"; FileChannel channel = new RandomAccessFile(path, mode).getChannel(); // some code to write to this file // finally delete File…
Victor
  • 1,207
  • 2
  • 13
  • 21
5
votes
3 answers

How to read a TIFF file by tiles with Java?

Let's say I have a very large TIFF image as input. I am not able to load this image entirely because of memory specification I must comply with. So the following is not an option : BufferedImage data = ImageIO.read(image); Is there any Java library…
5
votes
1 answer

FileOutputstream.close() is not always writing bytes to file system?

After reading this answer from @Peter Lawrey and especially this sentence : close() can ensure the file is actually written to disk (or not depending on the OS) (emphasis is mine.) I have 3 questions : Is it true that there is no guaranty that…
ben75
  • 29,217
  • 10
  • 88
  • 134
5
votes
3 answers

I Am Not Getting the Result I Expect Using readLine() in Java

I am using the code snippet below, however it's not working quite as I understand it should. public static void main(String[] args) { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line; try { …
Aaron
  • 23,450
  • 10
  • 49
  • 48
5
votes
1 answer

Does argument/parameters InputStream need to be closed in android?

All stream and bufferedReader need to be closed my question is what if the stream and bufferedReader is inside a method arguments/parameters need to be closed also? example normal code: InputStream i = entity.getContent(); i.close(); Q: What if…
Piolo Opaw
  • 1,471
  • 2
  • 15
  • 21
5
votes
2 answers

Java (J2SE) DTMF tone detection

I am trying to do the following I am getting a call to another person using my java application (Already done & works fine). Then I am playing a recording, for example "Please press 1 one to continue in english" (Already done & works fine). …