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...
Bewick asked 2/11, 2012 at 14:1

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...
Hebdomad asked 22/6, 2010 at 6:27

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();...
Marcelenemarcelia asked 29/3, 2012 at 14:21

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...
Mouton asked 2/2, 2011 at 5:24

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 )
Unsound asked 23/3, 2012 at 10:38

4

Solved

I am writing a java program to read the error stream from a process . Below is the structure of my code -- ProcessBuilder probuilder = new ProcessBuilder( command ); Process process = probuilder....
Leukocyte asked 16/10, 2012 at 6:28

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...
Salyer asked 9/3, 2015 at 16:38

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...
Sextillion asked 30/12, 2011 at 20:47

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 ...
Bodily asked 23/11, 2021 at 2:58

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...
Trogon asked 31/10, 2013 at 9:27

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...
Pandybat asked 11/7, 2013 at 13:45

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...
Hardcore asked 8/4, 2021 at 2:12

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 ...
Unfrock asked 25/1, 2012 at 16:11

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");
Monoplegia asked 19/11, 2011 at 20:28

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...
Sainthood asked 12/4, 2011 at 20:16

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

© 2022 - 2024 — McMap. All rights reserved.