ioexception

IOException was unhandled

狂风中的少年 提交于 2019-12-12 02:27:50
问题 i have a application which crops an image and save it the process was to load an image, crop it, delete the original image(so i can replace it) and, save it. this is my code: private void DetectSize(object sender, EventArgs e) { int x = 1; Bitmap TempImage = new Bitmap(@cwd + "\\t" + (x + 1) + ".jpg", true); pictureBox.Image = (Image)TempImage.Clone(); TempImage.Dispose(); Bitmap imgPart = new Bitmap(pictureBox.Image); int imgHeight = imgPart.Height; int imgWidth = imgPart.Width; HalfWidth =

IOException in ObjectInputStream in java

守給你的承諾、 提交于 2019-12-12 01:38:29
问题 I have problem with my code. I get IOException when I use readObject in my code. the whole program work correctly but when I want to use readObject I get this exception, this is the code I use for saving object: File f = new File("employees.obj"); ObjectOutputStream objOut = null; try { objOut = new ObjectOutputStream(new BufferedOutputStream( new FileOutputStream(f))); objOut.writeObject(newEmployee); objOut.flush(); System.out.println("Object is serialized."); } catch (FileNotFoundException

IO operation aborted error thrown while reading serial port

余生颓废 提交于 2019-12-11 23:23:34
问题 We are trying to read data written by an external device (weighing scale in this case) connected to serial port using .Net serial port class. First we initialize the serial port as below: InitializeSerialPort() { if ((serialPort != null) && (serialPort.IsOpen)) { serialPort.Close(); serialPort.Dispose(); serialPort = null; } serialPort = new SerialPort("COM2", 9600, Parity.None, 8, StopBits.One) { Handshake = Handshake.None }; serialPort.DataReceived += serialPort_DataReceived; serialPort

FileOutputStream close when out of space

落爺英雄遲暮 提交于 2019-12-11 19:23:20
问题 I've come across a problem using FileOutputStream and BufferedWriter in Java. If my disk space is full and I'm trying to write, it will throw IOException (which is correct), but when calling the writer.close(), it will fail to close the resource, throwing another IOException and keeping the resource opened! Here is my workaround with writer.flush() . It seems to work, but is there a better way to handle this? BufferedWriter writer = null; try { writer = new BufferedWriter(new

System.IOException when opening file with File.OpenRead

走远了吗. 提交于 2019-12-11 17:26:42
问题 I get the following exception when I open a file for unzipping it's contents. It happens when I have the file selected in Windows Explorer, or mouse over it showing a tooltip. System.IO.IOException was unhandled Message=The process cannot access the file 'D:\Documents\AutoUnZip\Zips\MVCContrib.Extras.release.zip' because it is being used by another process. Source=mscorlib StackTrace: at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String

Application.GetResourceStream throws IOException

[亡魂溺海] 提交于 2019-12-11 14:13:48
问题 I'm working on a Version History dialog box, and I created a sample to test it. It seems, however, that the sample can't find the HTML file: var dlg = new VersionHistoryDialog(); var uri = new Uri(@"pack://application:,,,/VersionHistory.html", UriKind.Absolute); var source = Application.GetResourceStream(uri).Stream; // This line throws the error dlg.Stream = source; var result = dlg.ShowDialog(); label1.Content = result; That line in the code above throws this error: System.IO.IOException

Android HttpUrlConnection Url doesn't work on emulator

本秂侑毒 提交于 2019-12-11 12:36:10
问题 I am trying to get json object as string from this url http://digitalcollections.tcd.ie/home/getMeta.php?pid=MS4418_021. It doesn't work I get an error after downloadUrl function. java.io.IOException: unexpected end of stream on Connection{digitalcollections.tcd.ie:80, proxy=DIRECT@ hostAddress=134.226.115.12 cipherSuite=none protocol=http/1.1} (recycle count=0) Although it does work for this androidhive url http://api.androidhive.info/volley/person_object.json. I am new to httpconnection

The need to catch IOExceptions & Exceptions

徘徊边缘 提交于 2019-12-11 12:03:50
问题 Should one always catch an IOException/Exception if a program reading in a txt file using a scanner object produces nothing but a FileNotFoundException? Would such extra code be unneeded or important? import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class TestingScanner { public TestingScanner() { readFile("dummy.txt"); } public void readFile(String filePath) { File file = new File(filePath); Scanner scanner = null; try { scanner = new Scanner(file);

Getting java.io.IOException when running JUnit test case in Eclipse

喜夏-厌秋 提交于 2019-12-11 10:48:01
问题 Here's my code public class JWebUnitTest extends WebTestCase { public JWebUnitTest(String name) { super(name); } public void setUp() { getTestContext().setBaseUrl("http://www.google.com"); } public void testSearch() { beginAt("/"); setFormElement("q", "httpunit"); submit("btnG"); clickLinkWithText("HttpUnit"); assertTitleEquals("HttpUnit"); assertLinkPresentWithText("User's Manual"); } } In the Failure Trace, I see the following error: java.lang.RuntimeException: java.io.IOException (moving

Get Location Name by passing Latitude and Longitude in android

北慕城南 提交于 2019-12-11 08:25:14
问题 I have written following code for getting location name : UseGpsActivity.java public class UseGpsActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); /* Use the LocationManager class to obtain GPS locations */ boolean gps_is_enabled = false; LocationManager mlocManager = (LocationManager) this .getSystemService(Context.LOCATION_SERVICE); List