java-io Questions

2

Solved

Initially I had the following code: Attempt 1 try (var output = new ByteArrayOutputStream(); var printer = new CSVPrinter(new OutputStreamWriter(output), CSVFormat.DEFAULT)) { printer.printReco...
Citizenry asked 27/11, 2019 at 19:28

5

Trying to troubleshoot an occasional java.nio.file.DirectoryNotEmptyException in a recursive delete method taken from Delete directories recursively in Java Code (credit to @TrevorRobinson) : stati...
Linlithgow asked 12/11, 2013 at 17:14

4

Solved

What is the best way to write bytes in the middle of a file using Java?
Machellemachete asked 8/10, 2008 at 5:0

3

I have a 35GB CSV file. I want to read each line, and write the line out to a new CSV if it matches a condition. try (BufferedWriter writer = Files.newBufferedWriter(Paths.get("source.csv"))) { t...
Documentary asked 22/10, 2019 at 9:47

6

Solved

I am trying to get a piece of code working. The aim is to check if there is an .XML file in a certain directory. This is what I've got so far. File f = new File("saves/*.xml"); if(f.exists()) {...
Lys asked 22/4, 2013 at 9:20

2

Solved

I referred some similar questions on SO but none of them deals with IO. I had used the same code in java when I used Eclipse. That time it worked. But now I try to use this code in Mono for Andro...
Stockist asked 28/3, 2012 at 11:54

5

Solved

I have a directory: File dir = new File(MY_PATH); I would like to list all the files whose name is indicated as integer numbers strings, e.g. "10", "20". I know I should use: dir.list(FilenameF...
Vernal asked 12/11, 2013 at 15:19

3

Solved

The applicationContext.xml is in the WEB-INF folder, why am i getting this error : org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path ...
Symmetry asked 25/9, 2012 at 0:55

0

I was wondering is there any way to update the symlink target without delete the old symlink. I have two pieces of code, which happens at same time. The first piece is downloading some data every ...
Jamima asked 10/7, 2019 at 16:42

2

Solved

I'm writing an android app and I need to read several files from several folders and add them to several zip archives. I need to limit the max size of the archives to lets say 16mb. So at runtime w...
Hort asked 18/6, 2012 at 14:20

0

I am using Spring boot 2.0.4, trying read a json file which is placed in resources/ directory, but getting the 'FileNotFoundException'. I have referred a lot of pages from Stackoverflow, and othe...
Penetrance asked 8/5, 2019 at 13:54

4

Solved

I've got code as below: class ListPageXMLFiles implements FileFilter { @Override public boolean accept(File pathname) { DebugLog.i("ListPageXMLFiles", "pathname is " + pathname); String rege...
Mussel asked 26/8, 2011 at 4:4

1

I have a number of temporary files that I call deleteOnExit() on. I also have a runnable that I register with addShutdownHook() to run when System.exit is called. Is there any guarantee that the...
Heteronomy asked 10/3, 2015 at 17:39

4

Solved

I need to be able to mimic tail -f with Java. I'm trying to read a log file as it's being written by another process, but when I open the file to read it, it locks the file and the other process ca...
Quickstep asked 29/3, 2010 at 10:52

2

Solved

I am looking at examples of try-with-resources in Java and I understand the following one: try (Connection conn = DriverManager.getConnection(url, user, pwd); Statement stmt = conn.createStatemen...
Austrasia asked 8/10, 2018 at 9:45

3

Solved

I'm processing a binary stream and need to skip efficiently past a range of data that I'm not interested in, to some data that will be processed. InputStream.skip(long) doesn't make much in the wa...
Wingard asked 27/12, 2012 at 16:18

1

Solved

I'm writing a program part simply to copy a file from source to a destination File. The code works as well it should but if there is a file large file the process of copy will end up, after the des...
Mulch asked 11/9, 2018 at 17:37

3

Solved

It's looks like java.io.File.(File, String) is JDK version dependent. Code example was run on Windows 10. Code example: public static void main(String... args) { String path = "C:\\Worksp...
Rust asked 3/9, 2018 at 13:54

3

Solved

I saw this example, and I didn't see the close() method invoked on the InputStream, so would prop.load() close the stream automatically? Or is there a bug in the example?
Selfinduced asked 17/10, 2016 at 3:36

6

Solved

I'm in the process of learning Java and I cannot find any good explanation on the implements Closeable and the implements AutoCloseable interfaces. When I implemented an interface Closeable, my Ec...
Foreboding asked 30/10, 2012 at 14:36

7

I'm reading sequential lines of characters from a text file. The encoding of the characters in the file might not be single-byte. At certain points, I'd like to get the file position at which the ...
Leilaleilah asked 3/6, 2015 at 18:11

6

Solved

What's the difference between those? I'm just learning Java ATM, but it seems like I can write to a file both ways i.e. (I didn't copy the try-catch block here.) FileWriter file = new FileWriter("...
Ctn asked 10/9, 2012 at 10:57

5

Solved

I am getting this error when I try to open a file: java.io.FileNotFoundException: D:\Portable%20Programs\Android%20Development\workspace3\XXX-desktop\bin\World_X.fr (The system cannot find the pat...
Unfreeze asked 19/7, 2012 at 16:55

6

Solved

I am trying to read a simple text file in my sample Android Application. I am using the below written code for reading the simple text file. InputStream inputStream = openFileInput("test.txt&q...
Aplenty asked 24/4, 2011 at 15:18

1

How do I read contents of all files present in a file with a 7z extension. Let's say I have abc.7z with part1.csv and part2.csv and xyz.7z with part3.csv and part4.csv. I want to read contents of...
Coppersmith asked 1/4, 2018 at 4:17

© 2022 - 2024 — McMap. All rights reserved.