ioexception

“Cannot run program” when using Runtime.exec with spaces in program filename

可紊 提交于 2019-12-01 22:58:25
I am using the below code to open the "sample.html' file. String filename = "C:/sample.html"; String browser = "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe"; Runtime rTime = Runtime.getRuntime(); Process pc = rTime.exec(browser + filename); pc.waitFor(); However, I am getting the below error. java.io.IOException: Cannot run program "C:/Program": CreateProcess error=2, The system cannot find the file specified Could someone please help me figure this. Thanks in advance. Runtime.exec(String) automatically splits the string at spaces, assuming the first token is the command name

How to identify whether folder is opened?

社会主义新天地 提交于 2019-12-01 17:56:00
问题 In my application I'm trying to rename the folder, but if the folder is opened in Windows Explorer I get an IOException . How can I identify whether folder is opened in Windows Explorer in C#? 回答1: catch the IOException? As others have said, just try to do what you want, catch the exception if it happens and take appropriate action, whatever that is in your context. You don't really have much choice as I see it, consider: bool iHaveAccess = CheckAccess(folder); if (iHaveAccess) { RenameFolder

How to identify whether folder is opened?

岁酱吖の 提交于 2019-12-01 17:45:32
In my application I'm trying to rename the folder, but if the folder is opened in Windows Explorer I get an IOException . How can I identify whether folder is opened in Windows Explorer in C#? catch the IOException? As others have said, just try to do what you want, catch the exception if it happens and take appropriate action, whatever that is in your context. You don't really have much choice as I see it, consider: bool iHaveAccess = CheckAccess(folder); if (iHaveAccess) { RenameFolder(folder,newFolderName); } what happens if between CheckAccess succeeding and calling RenameFolder something

what is java.io.IOException: invalid header field?

青春壹個敷衍的年華 提交于 2019-12-01 16:07:37
问题 When i try to run the following command : jar cvfm myjar.jar manifest.txt *.class I get the following exceptions : java.io.IOException: invalid header field at java.util.jar.Attributes.read(Attributes.java:410) at java.util.jar.Manifest.read(Manifest.java:199) at java.util.jar.Manifest.<init>(Manifest.java:69) at sun.tools.jar.Main.run(Main.java:171) at sun.tools.jar.Main.main(Main.java:1176) What could be the reason i am getting these exceptions ? 回答1: I'm guessing that there's a problem

c# Exception The process cannot access the file

邮差的信 提交于 2019-12-01 06:38:30
I'm getting an exception: The process cannot access the file. Here's the code: if (!Monitor.TryEnter(lockObject)) return; try { watcher.EnableRaisingEvents = false; try { XmlDocument xdoc = new XmlDocument(); xdoc.Load(FileName); xdoc = null; } catch (XmlException xe) { using (StreamWriter w = File.AppendText(FileName)) { Console.WriteLine(xe); w.WriteLine("</test>"); w.WriteLine("</testwrapper>"); } } System.Threading.Thread.Sleep(2000); XPathDocument myXPathDoc = new XPathDocument(new StreamReader(FileName, System.Text.Encoding.GetEncoding("windows-1256"))); XslCompiledTransform myXslTrans =

c# Exception The process cannot access the file

限于喜欢 提交于 2019-12-01 05:44:48
问题 I'm getting an exception: The process cannot access the file. Here's the code: if (!Monitor.TryEnter(lockObject)) return; try { watcher.EnableRaisingEvents = false; try { XmlDocument xdoc = new XmlDocument(); xdoc.Load(FileName); xdoc = null; } catch (XmlException xe) { using (StreamWriter w = File.AppendText(FileName)) { Console.WriteLine(xe); w.WriteLine("</test>"); w.WriteLine("</testwrapper>"); } } System.Threading.Thread.Sleep(2000); XPathDocument myXPathDoc = new XPathDocument(new

Unable to tunnel through proxy. Proxy returns HTTP/1.1 503 Service Unavailable

谁说胖子不能爱 提交于 2019-12-01 05:01:45
I want to connect to an intranet server, the url that I need to connect is: URLConnection conn = new URL("https://mywebsite").openConnection(); When I reach to the connect method call through:` conn.connect(); I'm getting the following exception: java.io.IOException: Unable to tunnel through proxy. Proxy rerurns HTTP/1.1 503 Service Unavailable" at sun.net.www.protocol.httpHttpURLConnection.doTunneling How can I solve this exception, I have tried many solutions published on the net, but without any luck. What helped to me was to unset all proxy properties in the environment ( http_proxy etc

Error writing to server

扶醉桌前 提交于 2019-12-01 03:55:17
I am uploading a file from one server to another server using a Java Program 'POST' method. But I am getting below exception. java.io.IOException: Error writing to server at sun.net.www.protocol.http.HttpURLConnection.writeRequests(HttpURLConnection.java:582) at sun.net.www.protocol.http.HttpURLConnection.writeRequests(HttpURLConnection.java:594) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1216) at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:379) at com.test.rest.HttpURLConnectionExample.TransferFile(HttpURLConnectionExample.java

java.io.FileNotFoundException for valid URL

两盒软妹~` 提交于 2019-12-01 03:51:39
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 exception from my application java.io.FileNotFoundException: http://planet.rubyonrails.ru/xml/rss at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1311) at com.sun.syndication.io.XmlReader.<init>(XmlReader.java:237) at com.sun.syndication

Unable to tunnel through proxy. Proxy returns HTTP/1.1 503 Service Unavailable

半城伤御伤魂 提交于 2019-12-01 02:44:04
问题 I want to connect to an intranet server, the url that I need to connect is: URLConnection conn = new URL("https://mywebsite").openConnection(); When I reach to the connect method call through:` conn.connect(); I'm getting the following exception: java.io.IOException: Unable to tunnel through proxy. Proxy rerurns HTTP/1.1 503 Service Unavailable" at sun.net.www.protocol.httpHttpURLConnection.doTunneling How can I solve this exception, I have tried many solutions published on the net, but