ioexception

Safest way to copy a file

Hello, I need to merg two PDF files. However sometimes a file might be locked up I wrote this code, but I'm wondering if it's not the smartest solution: private static int FILE_LOCKED_WAIT_PERIOD = 1000; while (true) { // If the file is in use, IOException will be thrown. ...

How can I programmatically tell if a caught IOException is because the file is being used by another process, without resorting to parsing the exception's Message property?

When I open a file, I want to know if it is being used by another process so I can perform special handling; any other IOException I will bubble up. An IOException's Message property contains "The process cannot access the file 'foo' because it is being used by another process.", but this is unsuitable for programmatic detection. What is...

File.Replace throwing IOException

I have an app that can make modify images. In some cases, this makes the filesize smaller, in some cases bigger. The program doesn't have an option to "not replace the file if result has a bigger filesize". So I wrote a little C# app to try and solve this. Instead of overwriting the files, I make the app write the result to a folder u...

Getting IOException Push back buffer is full while trying to unzip a String value using ZipInputStream

I am trying to unzip a String value. But I am getting a java.io.IOException: Push back buffer is full public byte[] unzipArray(String stringToUnzip) { byte[] inputByteArray = Base64.decode(stringToUnzip); ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( inputByteArray)...

Java: what are IOEXceptions in BufferedReader's readLine() for?

I can "fix" the below exception with a try-catch loop but I cannot understand the reason. Why does the part "in.readLine()" continuosly ignite IOExceptions? What is really the purpose of throwing such exceptions, the goal probably not just more side effects? Code and IOExceptions $ javac ReadLineTest.java ReadLineTest.java:9: unr...

Regarding playing media file in Android media player application

Hi. I am new to android development. I just started with creating my own media player application by looking at the code samples given in Android SDK. While I am trying to play a local media file (m.3gp), I am getting IOException error :: error(1,-4). Please can somebody help me in this regard. Here is my code. package com.mediaPlaye...

How do I close a file after catching an IOException in java?

All, I am trying to ensure that a file I have open with BufferedReader is closed when I catch an IOException, but it appears as if my BufferedReader object is out of scope in the catch block. public static ArrayList readFiletoArrayList(String fileName, ArrayList fileArrayList) { fileArrayList.removeAll(fileArrayList); try { ...

Is there a limit for the number of files in a directory on an SD card?

I have a project written for Android devices. It generates a large number of files, each day. These are all text files and images. The app uses a database to reference these files. The app is supposed to clear up these files after a little use (perhaps after a few days), but this process may or may not be working. This is not the subjec...

Get the file from IOException object

Is there a way to get from the IOException object the file that fails? ...

Java: Clearing up the confusion on what causes a connection reset

There seems to be some confusion as well contradicting statements on various SO answers: http://stackoverflow.com/questions/585599/whats-causing-my-java-net-socketexception-connection-reset . You can see here that the accepted answer states that the connection was closed by other side. But this is not true, closing a connection doesn't c...

when does java.util.zip.ZipFile.close() throw IOException?

Under what circumstances would java.util.zip.ZipFile.close() throw an IOException? Its method signature indicates that it can be thrown, but from the source code there doesn't seem to be any place where this could happen, unless it's in native code. What corrective action, if any, could be taken at the point where that exception is caugh...

java.io.FileNotFoundException for valid URL

Hello. I use library rome.dev.java.net to fetch RSS. Code is URL feedUrl = new URL("http://planet.rubyonrails.ru/xml/rss"); SyndFeedInput input = new SyndFeedInput(); SyndFeed feed = input.build(new XmlReader(feedUrl)); You can check that http://planet.rubyonrails.ru/xml/rss is valid URL and the page is shown in browser. But I get e...

What does "Insufficient system resources..." error mean?

This question spans both serverfault and stackoverflow so I just picked this one. I get the following exception with some simple file copy code. Its running on Windows Server 2003 x64 Caused by: java.io.IOException: Insufficient system resources exist to complete the requested service at sun.nio.ch.FileDispatcher.pwrite0(Native Method...

xml pull parser assets xml

how can i parse a local xml file in the assets folder using pull parser. cant get pull parser to work, always throws io exception. i think i cant get the path to the file, or connecting to the file help please! ...

Regarding IllegalStateExceptions, MediaPlayer, failed prepares and State codes

Hi, I have been struggling quite a lot with our beloved MediaPlayer class... Specifically I want to simply play sounds from some Files... I am getting two specific types of errors actually, and not continuesly but it seems like random... Sometimes 10 files are played rigth away with no errors, then the MediPlayer seems to stop accepting...

IOException when running Android projects in Eclipse

Every time I try to run an Android project from Eclipse with the Android plugin (Run -> Run), the emulator starts up just fine, but the upload fails, and the Console puts out this error message: [2010-06-17 08:17:55 - HelloAndroid] Failed to upload HelloAndroid.apk on device 'emulator-5554' [2010-06-17 08:17:55 - HelloAndroid] java.io.I...

StreamReader.EndOfStream produces IOException

I'm working on an application that accepts TCP connections and reads in data until an </File> marker is read and then writes that data to the filesystem. I don't want to disconnect, I want to let the client sending the data to do that so they can send multiple files in one connection. I'm using the StreamReader.EndOfStream around my out...

Emulate waiting on File.Open in C# when file is locked

I have, essentially, the same problem as this poster, but in C#: http://stackoverflow.com/questions/1746781/waiting-until-a-file-is-available-for-reading-with-win32 More information: we have code that calls File.Open in one of our projects, that occasionally dies when the file is already opened by another process (EDIT: or thread): Fil...

How to do HTTPS with TcpClient just like HttpWebRequest does?

I've got a communication system based on TcpClient, and it works great except for when it's doing HTTPS to a particular IP. Then it starts to fail. By using a browser or HttpWebRequest, I have no problems doing HTTPS to that IP. I've created a test program to narrow my problem down to its basic essence, you can have a look at it here ...

Blackberry Http Connection times out on image download. Why?

My application loops through about 200 urls that are all jpg images. In the simulator it reads ok, then stores the byte array in persistentStore with no problems. On the device, it gives java.io.IOException: TCP read timed out on basically every image. Every now and then, one gets through. Not even sure how. The image sizes don't give in...