java-io Questions
3
Solved
How are mark() and reset() methods working exactly(in code below), step by step ? I tried to write my own example but is starts to throw wrong mark exception or similar to that, and I cannot unders...
2
Solved
According to the documentation of AsynchronousFileChannel and AsynchronousChannelGroup, async NIO is using a dedicated thread pool where "IO events are handled". I couldn't find any clear...
Fusiform asked 10/7, 2020 at 20:54
4
Solved
When using
file.createNewFile();
I get the following exception
java.io.IOException: Parent directory of file does not exist: /.../pkg/databases/mydb
I am wondering is there a createNewFile that c...
3
Solved
I have some codes like this:
PrintWriter pw = new PrintWriter(new BufferedReader(....));
for(int i=0; i<10; i++) {
pw.println("a");
pw.flush();// flush each time when println()?
}
pw.close();...
27
I want to access my current working directory using Java.
My code:
String currentPath = new java.io.File(".").getCanonicalPath();
System.out.println("Current dir:" + currentPa...
8
Solved
Is there any way InputStream wrapping a list of UTF-8 String? I'd like to do something like:
InputStream in = new XyzInputStream( List<String> lines )
4
Solved
9
Solved
The condition is if the directory exists it has to create files in that specific directory without creating a new directory.
The below code only creates a file with the new directory but not for th...
3
Solved
I want to save a BufferedImage (named "result"):
boolean bres = ImageIO.write(result, ".png", new File(saveP));
But bres is always null.
This
ImageIO.getWriterFormatNames()
returns that:
...
Seethrough asked 13/3, 2014 at 8:42
7
Solved
I have a program that I'm writing where I am using another company's library to download some reports from their website. I want to parse these reports before I write them to a file, because if the...
7
I am reading a file containing keywords line by line and found a strange problem.
I hope lines that following each other if their contents are the same, they should be handled only once. Like
son...
Boston asked 9/6, 2011 at 8:49
2
I was creating an application to test whether File.listFiles() method is working or not. To check this I made an application and I used it there but this returning null in place of an array.
This i...
Cowbell asked 18/6, 2021 at 9:38
2
How can we write a byte array to a file (and read it back from that file) in Java?
Yes, we all know there are already lots of questions like that, but they get very messy and subjective due to the ...
8
Solved
The Java.iO.File document says the following words about its constructor which takes the pathname:
public File(String pathname)
Creates a new File instance by converting the given pathname st...
4
Solved
How can I create new File (from java.io) in memory, not on the hard disk?
I am using the Java language. I don't want to save the file on the hard drive.
I'm faced with a bad API (java.util...
17
Solved
I have this code which reads all the files from a directory.
File textFolder = new File("text_directory");
File [] texFiles = textFolder.listFiles( new FileFilter() {
public boolean accept( Fi...
Macule asked 15/9, 2009 at 19:28
9
Solved
I'm developing an android application where I'm sending requests to the web server and parsing JSON objects. Frequently I'm getting java.net.SocketTimeoutException: Connection timed out exception w...
Hatty asked 25/3, 2013 at 5:52
2
Solved
This is my first time working with Files.walk in Java, and I rather like it, especially the Path class. It's robust and versatile.
What I'm not liking, however, is that when walking a folder, if th...
5
Solved
I have an array of strings ( actually it's an ArrayList ) and I would like to create an InputStream from it, each element of the array being a line in the stream.
How can I do this in the easiest ...
2
Solved
Java 14 introduces a new annotation @Serial in the java.io package. Its brief description in the API docs:
Indicates that an annotated field or method is part of the serialization mechanism define...
Phenacaine asked 7/9, 2020 at 19:51
10
Solved
How to get ddd from the path name where the test.java resides.
File file = new File("C:/aaa/bbb/ccc/ddd/test.java");
7
Solved
Is there anyway to check whether an OutputStream is closed without attempting to write to it and catching the IOException?
For example, consider the following contrived method:
public boolean isS...
Portraitist asked 28/12, 2011 at 12:24
6
Solved
to get the content of a txt file I usually use a scanner and iterate over each line to get the content:
Scanner sc = new Scanner(new File("file.txt"));
while(sc.hasNextLine()){
String str = sc.ne...
9
Solved
I am reading a file via the BufferedReader
String filename = ...
br = new BufferedReader( new FileInputStream(filename));
while (true) {
String s = br.readLine();
if (s == null) break;
...
}
...
Typhon asked 24/5, 2011 at 16:10
3
Solved
I have the following java code in Spring framework to convert a multipart file to a regular file:
public static File convertToFile(MultipartFile multipart) {
File convFile = null;
try {
convFi...
Everhart asked 5/5, 2018 at 8:14
1 Next >
© 2022 - 2024 — McMap. All rights reserved.