ioexception

Write end dead exception using PipedInputStream java

坚强是说给别人听的谎言 提交于 2019-11-26 18:27:17
问题 Write end dead exception occurs in the following situation: Two threads: A: PipedOutputStream put = new PipedOutputStream(); String msg = "MESSAGE"; output.wirte(msg.getBytes()); output.flush(); B: PipedInputStream get = new PipedOutputStream(A.put); byte[] get_msg = new byte[1024]; get.read(get_msg); Here is the situation: A and B run concurrently, and A writes to the pipe and B reads it. B just read from the pipe and buffer of this pipe is cleared. Then A doesn't write msg to the pipe in

Error message “unreported exception java.io.IOException; must be caught or declared to be thrown”

我与影子孤独终老i 提交于 2019-11-26 17:49:42
Error: filecontent.java:15: unreported exception java.io.IOException; must be caught or declared to be thrown showfile(); ^ filecontent.java:78: unreported exception java.io.IOException; must be caught or declared to be thrown showfile(); ^ I have already thrown java.io.IOException, but still it shows these errors. My code: import java.awt.*; import java.awt.event.*; import java.io.*; class filecontent extends Frame implements ActionListener { TextField t[] = new TextField[4]; TextArea ta[] = new TextArea[4]; Button submit; Panel p1; filecontent() { setGUI(); setRegister(); showfile();

Java: Exception itself is null

假装没事ソ 提交于 2019-11-26 17:00:45
问题 I am pretty confused. Is it an Android problem or a problem with Java itself? When I was debugging an Android application which works with Bluetooth, the flow stopped on an catch block of IOException in which I later found out that exception e was null.... It was thrown when I was trying to read from an InputStream. Yes, it was not a NullPointerException , but some other kind of exception which is null - better say thrown un-initialized. Is it possible? In which scenario can such unitialized

Wait for file to be freed by process

守給你的承諾、 提交于 2019-11-26 15:47:47
问题 How do I wait for the file to be free so that ss.Save() can overwrite it with a new one? If I run this twice close together(ish), I get a generic GDI+ error. ///<summary> /// Grabs a screen shot of the App and saves it to the C drive in jpg ///</summary> private static String GetDesktopImage(DevExpress.XtraEditors.XtraForm whichForm) { Rectangle bounds = whichForm.Bounds; // This solves my problem but creates a clutter issue // var timeStamp = DateTime.Now.ToString("ddd-MMM-dd-yyyy-hh-mm-ss")

Unable to read data from the transport connection : An existing connection was forcibly closed by the remote host

大憨熊 提交于 2019-11-26 10:31:38
I have a server app and sometimes, when the client tries to connect, I get the following error: NOTE: the "couldn't get stream from client or login failed" is a text that's added by me in catch statement and the line at which it stops ( sThread : line 96 ) is : tcpClient = (TcpClient)client; clientStream = tcpClient.GetStream(); sr = new StreamReader(clientStream); sw = new StreamWriter(clientStream); // line 96: a = sr.ReadLine(); What may be causing this problem? Note that it doesn't happen all the time This error usually means that the target machine is running, but the service that you're

Does close ever throw an IOException?

社会主义新天地 提交于 2019-11-26 09:47:11
问题 After providing some answers here, and reading some comments, it would seem that, in practice IOException is never thrown on close for file I/O. Are there any cases in which calling close on a Stream/Reader/Writer actually throws an IOException? If an exception is actually thrown, how should it be dealt with? 回答1: For files, you may not see IOException thrown often on close(), but you'll definitely see it for non-File I/O like closing sockets to the network. Here's an example of a Java bug

How to check if IOException is Not-Enough-Disk-Space-Exception type?

戏子无情 提交于 2019-11-26 08:10:03
问题 How can I check if IOException is a \"Not enough disk space\" exception type? At the moment I check to see if the message matches something like \"Not enough disk space\", but I know that this won\'t work if the OS language is not English. 回答1: You need to check the HResult and test against ERROR_DISK_FULL (0x70) and ERROR_HANDLE_DISK_FULL (0x27), which can be converted to HResults by OR'ing with 0x80070000. For .Net Framework 4.5 and above, you can use the Exception.HResult property: static

MediaPlayer.setDataSource causes IOException for valid file

空扰寡人 提交于 2019-11-26 07:46:30
问题 This code used to work. Then, maybe I changed something, somewhere (or if I know Android right, an update introduced a bug in the media player). It stopped working on some devices! Especially my Nexus S (2.3.6). The file test.m4a (17 775 201 bytes) was downloaded by the app. To verify its integrity, I copied it to the SD and played it on my PC. No problem! Also binary-compared it with the original file, and it matched 100%. try { _mediaPlayer = new MediaPlayer(); _mediaPlayer

Cannot delete file used by some other process

浪子不回头ぞ 提交于 2019-11-26 06:49:12
问题 I am displaying some image in my wpf app using following code: <Image Source=\"{Binding Path=TemplateImagePath, Mode=TwoWay}\" Grid.Row=\"3\" Grid.Column=\"2\" Width=\"400\" Height=\"200\"/> and setting it\'s binding property inside code behind\'s constructor by navigating through some directory, below is the code: DirectoryInfo Dir = new DirectoryInfo(@\"D:/Template\"); if (Dir.Exists) { if (Dir.GetFiles().Count() > 0) { foreach (FileInfo item in Dir.GetFiles()) { TemplateImagePath = item

Error message “unreported exception java.io.IOException; must be caught or declared to be thrown”

好久不见. 提交于 2019-11-26 04:51:32
问题 Error: filecontent.java:15: unreported exception java.io.IOException; must be caught or declared to be thrown showfile(); ^ filecontent.java:78: unreported exception java.io.IOException; must be caught or declared to be thrown showfile(); ^ I have already thrown java.io.IOException, but still it shows these errors. My code: import java.awt.*; import java.awt.event.*; import java.io.*; class filecontent extends Frame implements ActionListener { TextField t[] = new TextField[4]; TextArea ta[] =