标签: ioexception

IOException - detail message all question marks

I want to createNewFile with a path but I got an IOException. The question is, the detailed message cannot be interpreted, I can only see a bunch of question marks.

在此处输入图片说明

I am with Windows 10 originally in Spanish, but with Chinese language pack installed. The java language already set to en and file encoding UTF-8:

java -version
Picked up _JAVA_OPTIONS: -Duser.country=US -Duser.language=en -Dfile.encoding=UTF-8
openjdk version "11" 2018-09-25
OpenJDK Runtime Environment 18.9 (build 11+28)
OpenJDK 64-Bit Server VM 18.9 (build …
Run Code Online (Sandbox Code Playgroud)

java ioexception java-11

7
推荐指数
1
解决办法
202
查看次数

java.util.zip.ZipFile.close()什么时候抛出IOException?

在什么情况下java.util.zip.ZipFile.close()会抛出IOException?它的方法签名表明它可以被抛出,但是从源代码中似乎没有任何可能发生这种情况的地方,除非它是在本机代码中.如果有异常,可以采取哪些纠正措施?

java zip ioexception

6
推荐指数
1
解决办法
3046
查看次数

C# 进程无法访问文件“”,因为它正在被另一个进程使用

代码片段只是应该将字符串写入名为“all_results.txt”的文本文件中。我在 File.WriteAllText 中实现时出错。在网上搜索解决方案后,我尝试使用 FileStream 和 StreamWriter 作为替代品。问题仍然存在。

它给了我:

IOException 未处理:进程无法访问文件“C:\Users\MadDebater\Desktop\ConsoleTest1\ConsoleTest\bin\Debug\all_results.txt”,因为它正在被另一个进程使用。

奇怪的是,错误是任意发生的。它可能是在第 3 次循环期间或第 45 次循环期间发生错误。我提供了该类的完整代码,以防问题比看起来更严重。我确信这与我的病毒扫描程序或类似的东西无关。

try
                {
                    using (FileStream stream = new FileStream(@"all_results.txt", FileMode.Create)) // Exception here
                {
                    using (StreamWriter writer = new StreamWriter(stream))
                    {
                        writer.WriteLine(result);
                        writer.Dispose();
                        writer.Close();
                    }

                    stream.Dispose();
                    stream.Close();
                }

                }
                catch (IOException ex)
                {
                    Console.WriteLine(ex);
                }
Run Code Online (Sandbox Code Playgroud)

即使我尝试这样做,它仍然失败。

try
                {
                    File.WriteAllText(@"all_results.txt", result); // Exception here
                }
                catch (IOException ex)
                {
                    Console.WriteLine(ex.Message);
                }
Run Code Online (Sandbox Code Playgroud)

以下是该类的完整代码。它的目的是接收 Twitter 推文列表,并使用贝叶斯分类将它们一一分类。

    using System;
    using System.IO;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using BayesClassifier;
    using …
Run Code Online (Sandbox Code Playgroud)

c# asp.net visual-studio-2010 ioexception

6
推荐指数
1
解决办法
4万
查看次数

IOException - 无法加载文件

我有一个显示GIF图像的应用程序.如果图像保存在drawable中,一切正常,我就像这样访问它

is=context.getResources().openRawResource(R.drawable.mygif);
movie = Movie.decodeStream(is);
Run Code Online (Sandbox Code Playgroud)

但我需要从互联网上下载图像,所以我将它保存到CacheDir,这很好.我尝试了下面的内容来阅读它.

    try
    {
        is = new BufferedInputStream(new FileInputStream(new File(context.getCacheDir(), "mygif.gif")));
    }
    catch (FileNotFoundException e)
    {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    movie = Movie.decodeStream(is);
Run Code Online (Sandbox Code Playgroud)

还有这个

movie = Movie.decodeFile(new File(context.getCacheDir(), "mygif.gif").getPath());
Run Code Online (Sandbox Code Playgroud)

但无论如何,它都以

java.io.IOException
at java.io.InputStream.reset(InputStream.java:218)
at android.graphics.Movie.decodeStream(Native Method)
at android.graphics.Movie.decodeTempStream(Movie.java:74)
at android.graphics.Movie.decodeFile(Movie.java:59)
Run Code Online (Sandbox Code Playgroud)

要么

java.io.IOException: Mark has been invalidated.
at java.io.BufferedInputStream.reset(BufferedInputStream.java:350)
at android.graphics.Movie.decodeStream(Native Method)
Run Code Online (Sandbox Code Playgroud)

我认为这是一个非常简单的错误,但我无法克服它.清单有:

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
Run Code Online (Sandbox Code Playgroud)

file-io android ioexception

6
推荐指数
1
解决办法
4921
查看次数

使用Nutch进行爬网...显示IOException

我开始使用Nutch,一切都很好,直到遇到IOException异常,

$ ./nutch crawl urls -dir myCrawl -depth 2 -topN 4
cygpath: can't convert empty path
solrUrl is not set, indexing will be skipped...
crawl started in: myCrawl
rootUrlDir = urls
threads = 10
depth = 2
solrUrl=null
topN = 4
Injector: starting at 2012-06-23 03:37:51
Injector: crawlDb: myCrawl/crawldb
Injector: urlDir: urls
Injector: Converting injected urls to crawl db entries.
Exception in thread "main" java.io.IOException: Failed to set permissions of path: \tmp\hadoop-Rahul\mapred\staging\Rahul255889423\.staging to 0700
    at org.apache.hadoop.fs.FileUtil.checkReturnValue(FileUtil.java:682)
    at org.apache.hadoop.fs.FileUtil.setPermission(FileUtil.java:655) …
Run Code Online (Sandbox Code Playgroud)

java open-source web-crawler nutch ioexception

6
推荐指数
1
解决办法
2547
查看次数

WebRequest.Create抛出IOException"指定的注册表项不存在."

我正在调用这行代码来访问azure服务器:

var request = (HttpWebRequest)WebRequest.Create(uri);
Run Code Online (Sandbox Code Playgroud)

并收到此例外.有人知道怎么用它来管理吗?

mscorlib.dll!Microsoft.Win32.RegistryKey.Win32Error(int errorCode, string str) + 0x189 bytes    
mscorlib.dll!Microsoft.Win32.RegistryKey.GetValueKind(string name) + 0x7f bytes 
System.dll!System.Net.HybridWebProxyFinder.InitializeFallbackSettings() + 0xb8 bytes    
System.dll!System.Net.HybridWebProxyFinder.HybridWebProxyFinder() + 0x1e bytes  
[Native to Managed Transition]  
[Managed to Native Transition]  
System.dll!System.Net.HybridWebProxyFinder.HybridWebProxyFinder(System.Net.AutoWebProxyScriptEngine engine) + 0x37 bytes    
System.dll!System.Net.AutoWebProxyScriptEngine.AutoWebProxyScriptEngine(System.Net.WebProxy proxy, bool useRegistry) + 0x190 bytes  
System.dll!System.Net.WebProxy.UnsafeUpdateFromRegistry() + 0x67 bytes  
System.dll!System.Net.WebProxy.WebProxy(bool enableAutoproxy) + 0x44 bytes  
System.dll!System.Net.Configuration.DefaultProxySectionInternal.DefaultProxySectionInternal(System.Net.Configuration.DefaultProxySection section) + 0x3d9 bytes 
System.dll!System.Net.Configuration.DefaultProxySectionInternal.GetSection() + 0xbe bytes   
System.dll!System.Net.WebRequest.InternalDefaultWebProxy.get() + 0x7e bytes 
System.dll!System.Net.HttpWebRequest.HttpWebRequest(System.Uri uri, System.Net.ServicePoint servicePoint) + 0x18d bytes 
System.dll!System.Net.HttpRequestCreator.Create(System.Uri Uri) + 0x50 bytes …
Run Code Online (Sandbox Code Playgroud)

.net c# registry webrequest ioexception

6
推荐指数
1
解决办法
6377
查看次数

Scala 在不同的工作目录上运行进程

我无法使用 Process("dir/e.exe") 因为 e 需要在它自己的目录上执行,否则它无法访问其资源。但每当我尝试更改工作目录时,我都会收到异常:

Process("e.exe", new File(dir)) 
Process("e.exe", new File("\"+ dir))
Process("e.exe", new File(new File(dir).getCanonicalPath()))  

Caused by: java.io.IOException: Cannot run program "e.exe" (in directory ".
\dir"): CreateProcess error=2, The system cannot find the file specified
Run Code Online (Sandbox Code Playgroud)

这些不起作用,它们给了我完全相同的错误。还有其他选择吗?

编辑:这就是我的目录的样子:

MyFolder:
|-app.jar
|-folderWithExe
  \-e.exe
Run Code Online (Sandbox Code Playgroud)

scala process ioexception

6
推荐指数
1
解决办法
2261
查看次数

如何为 IOException 编写 junit 测试用例

我想在 JUNIT 测试中检查 IOException 类。这是我的代码:

public void loadProperties(String path) throws IOException {
  InputStream in = this.getClass().getResourceAsStream(path);
  Properties properties = new Properties();
  properties.load(in);
  this.foo = properties.getProperty("foo");
  this.foo1 = properties.getProperty("foo1");
}
Run Code Online (Sandbox Code Playgroud)

当我尝试给出错误的属性文件路径时,它给出了 NullPointerException。我想对其进行 IOException 和 Junit 测试。非常感谢您的帮助。

java junit ioexception

6
推荐指数
1
解决办法
2万
查看次数

好的http。异常 java.io.IOException:连接上的流意外结束

我遇到了一个问题,大约三分之一的OkHttpClient newCall(request).execute();服务器请求因以下异常而失败:

Exception java.io.IOException: unexpected end of stream on Connection{[REDACTED_DOMAIN_NAME]:80, proxy=DIRECT@ hostAddress=[REDACTED_DOMAIN_NAME]/[REDACTED_IP_ADDRESS] cipherSuite=none protocol=http/1.1}
Run Code Online (Sandbox Code Playgroud)

我禁用了证书验证。这种行为的原因可能是什么?

android ioexception okhttp

6
推荐指数
1
解决办法
7255
查看次数

当前 MultipartFile 的 java.io.FileNotFoundException

我正在处理有关 MultipartFile 的奇怪行为。

我的项目是一个接收文本文件的 Spring Boot 后端。该文本文件作为 MultipartFile 出现。我想将此文件发送到辅助 Spring Boot 后端,该后端将在我的主后端读取该文件之前向该文件添加一些内容。这些内容更改不是强制性的,如果它们不存在,程序也不会崩溃。

要将 MultipartFile 发送到另一个后端,我必须将 MultipartFile 转换为 java.io.File。在执行此操作时,MultipartFile 会被破坏。

创建 java.io.File 后,BufferedReader 无法读取原始 MultipartFile。

重度编辑:

我的项目规格发生了变化,额外的后端被取消了。不过我仍然很好奇这里发生了什么。以下代码重现了我遇到的异常:

@CrossOrigin
@RestController
@RequestMapping("/dragon")
public class TestController {

    @PostMapping("/killFile")
    public String sendInFileHere(@Valid @RequestBody MultipartFile multipartFile) {
        if (multipartFile == null) {
            throw new IllegalArgumentException("File has to be Present");
        }
        File file = new File(multipartFile.getOriginalFilename());
        try {
            multipartFile.transferTo(file);
        } catch (IOException e) {
            e.printStackTrace();
        }
        BufferedReader reader;
        try {
            InputStream is = multipartFile.getInputStream(); //exception is thrown …
Run Code Online (Sandbox Code Playgroud)

java backend filenotfoundexception ioexception spring-boot

6
推荐指数
1
解决办法
6933
查看次数