java-io Questions
3
Solved
What does :
System.in.read()
return ? The documentation says :
Returns:
the next byte of data, or -1 if the end of the stream is reached.
But for example if I enter : 10 I get back 49 . Why is...
4
Solved
The question is similar to the following two questions.
Java InputStream blocking read
Why is the FileInputStream read() not blocking?
But I still cannot fully understand it.
So far I think th...
Wrest asked 5/3, 2013 at 8:11
1
I am using Java 7 File API. I wrote a class that is working fine on Ubuntu creating directories perfectly, but when I run same code on Windows then it is throwing error:
Exception in thread "main"...
Hizar asked 19/1, 2013 at 15:42
2
Solved
The RandomAccessFile constructor accepts a mode string specifying how a file should be open.
I'm confused about the difference between "rws" and "rwd" modes.
Here's what the docs state:
"rws" ...
1
We are using [WatchService][1] API (JDK 7) to track files created in my system. And up till now, it worked ok. Every file created on my system tracked by my program.
But we have trouble when we use...
Dildo asked 24/7, 2012 at 10:7
3
Solved
I'm running a thread and everytime it runs, It should be checking to see if there is a new line to read from the BufferedReader although, it gets stuck waiting for a line to exist, thus halting the...
Solita asked 28/11, 2012 at 1:9
4
Solved
I have to read txt files in my program. Im currently using FileReader and BufferedReader. I tried to use Scanner but its slower than FileReader and BufferedReader. Is there any class, which c...
2
Solved
I have a very strange behaviour during writing to a socket.
In my mobile client I'm using a socket which is initialized as follows:
private void initSocket()
{
socket = new Socket();
socke...
Anschluss asked 25/10, 2012 at 19:52
5
Solved
So, I'm feeding file data to an API that takes a Reader, and I'd like a way to report progress.
It seems like it should be straightforward to write a FilterInputStream implementation that wraps th...
Zackzackariah asked 27/8, 2009 at 7:39
4
Solved
I started with requirement of reading and writing files in from/in a directory on a remote Ubuntu machine.
First, I wrote a Java program that could read,write files from a shared folder on a remot...
1
Solved
Possible Duplicate:
Best Way to Write Bytes in the Middle of a File in Java
I have a file in which I need to write bytes.
I know at which position in the file I need to insert speci...
3
Solved
I have been trying to do a little project that needs an appendable ObjectOutputStream.
I have gone through a couple of solutions and i found this It seemed to solve my problem at first. But on furt...
Lasky asked 5/9, 2012 at 10:19
2
What causes this kind of error in Tomcat?
SEVERE: Exception loading sessions from persistent storage
java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException:
bean.Project...
Alternant asked 19/2, 2010 at 6:46
4
Solved
When I used the File.delete() method to delete a file, where is the deleted file? I am using a Mac and I don't see the file in the Trash. I want to know where the file is being stored at? Or if it ...
4
I have two methods to read Text File In java one using FileReader and Other File InputStream
FileReader fr=new FileReader("C:\\testq\\test.txt");
BufferedReader br=new BufferedReader(fr);
String s...
2
Solved
I am having weird behavior with Scanner. It will work with a particular set of files I am using when I use the Scanner(FileInputStream) constructor, but it won't with the Scanner(File) constructor....
Depressed asked 29/2, 2012 at 1:52
1
Solved
I have a normal pdf file A.pdf , a third party encodes the file in base64 and sends it to me in a webservice as a long string (i have no control on the third party).
My problem is that when i deco...
3
Solved
I have a directory that contains a lot of files. I want to delete the entire directory as well as all the files in it.
I want my code to wait until every File in that directory (including the dire...
Gratia asked 10/1, 2012 at 5:51
2
I have a Jar file that I have created using 3rd party library.
When I packaged the jar file, I am including several xml files inside it in a folder named data
data
- file1.xml
- file2.xml
- fil...
Mateusz asked 10/1, 2012 at 2:38
1
Solved
I know how to truncate a RandomAccess file so that bytes at the end are removed.
raf.getChannel().truncate(file.length() - 4);
or
raf.setLength(file.length() - 4);
But how to truncate a Rando...
Whistler asked 2/1, 2012 at 16:32
4
Solved
I'm writing a simple program in Java and it requires reading data from a text file. However, I'm having trouble counting lines. The issue seems generic enough for a simple Google search but I may n...
Urbanity asked 2/12, 2011 at 5:13
6
Solved
In response to my answer to a file-reading question, a commenter stated that FileInputStream.read(byte[]) is "not guaranteed to fill the buffer."
File file = /* ... */
long len = file.length();
b...
Slapjack asked 25/5, 2011 at 13:1
3
Solved
Hi I have some code that uses block
RandomAccessFile file = new RandomAccessFile("some file", "rw");
FileChannel channel = file.getChannel();
// some code
String line = "some data";
ByteBuffer bu...
3
Solved
I have a method that does some IO, and I'd like to limit the calls (per second) to this method to avoid the backend to get bursts of concurrent requests it can't handle.
If the requirement came wi...
Dawkins asked 18/5, 2011 at 9:27
5
`I'm not sure what code to insert or even where, but I would like to check the number I enter is an odd number.
import java.io.*;
import javax.swing.JOptionPane;
public class Diamond {
public st...
© 2022 - 2024 — McMap. All rights reserved.