当我打开文件以解压缩其内容时,出现以下异常。当我在 Windows 资源管理器中选择文件或将鼠标悬停在显示工具提示的文件上时,就会发生这种情况。
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 path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
at System.IO.File.OpenRead(String path)
at AutoUnzip.SelectFolderForm.w_Changed(Object sender, FileSystemEventArgs e) in D:\Projects\WindowsForms\AutoUnzip\AutoUnzip\SelectFolderForm.cs:line 37
at System.IO.FileSystemWatcher.OnCreated(FileSystemEventArgs e)
at System.IO.FileSystemWatcher.NotifyFileSystemEventArgs(Int32 action, String name)
at …Run Code Online (Sandbox Code Playgroud) private void myFunction(String userName){
String fileName = this.generateFile(userName);
String[] command = new String[4];
command[0] = "cmd";
command[1] = "/C";
command[2] = "dir";
command[3] = "7za a "+ userName+".7z "+ fileName +" -p"+this.password;
try {
Process p = Runtime.getRuntime().exec(command);
BufferedReader stdInput = new BufferedReader(new
InputStreamReader(p.getInputStream()));
BufferedReader stdError = new BufferedReader(new
InputStreamReader(p.getErrorStream()));
while ((s = stdError.readLine()) != null) {
System.out.println(s);
}
ProcessBuilder proc = new ProcessBuilder(command[3]);
proc.start();
} catch(Exception e) {
System.out.println(e.toString());
e.printStackTrace();
}
}
Run Code Online (Sandbox Code Playgroud)
我尝试了两种在JAVA中运行命令行的方式。他们都没有工作。谁能告诉我我做错了什么。我尝试了 3 个小时但没有成功:(
我不断收到此错误 File Not Found …
当尝试解析网站的 html 页面时,它会因错误而崩溃:
java.io.IOException:标记已失效。
我的部分代码:
String xml = xxxxxx;
try {
Document document = Jsoup.connect(xml).maxBodySize(1024*1024*10)
.timeout(0).ignoreContentType(true)
.parser(Parser.xmlParser()).get();
Elements elements = document.body().select("td.hotv_text:eq(0)");
for (Element element : elements) {
Element element1 = element.select("a[href].hotv_text").first();
hashMap.put(element.text(), element1.attr("abs:href"));
}
} catch (HttpStatusException ex) {
Log.i("GyWueInetSvc", "Exception while JSoup connect:" + xml +" cause:"+ ex.getMessage());
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException("Socket timeout: " + e.getMessage(), e);
}
Run Code Online (Sandbox Code Playgroud)
我要解析的网站大小约为 2MB。当我调试代码时,我看到在 java 包ConstrainableInputStream.java方法中:
public void reset() throws IOException {
super.reset();remaining = maxSize - …Run Code Online (Sandbox Code Playgroud) 我试图引用计算机上的某个位置,但是Java告诉我语法错误.
这条线是否正确?
文件newlyUploadedFile = new File("D:\\"+ fileName);
问题是文件被正确上传到我希望它去的位置,但是我得到了错误:
java.io.IOException:文件名,目录名或卷标语法不正确
我正在尝试在程序中加载.csv文件但由于某种原因,它无法找到该文件.我应该在哪里放置文件?

安慰

我试图连接到服务器,而不是以Json格式接收一些数据.这是我的java代码:
HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet("https://my.server.com/validate/" + data);
request.setHeader("Accept", "application/json");
request.setHeader("X-AuthToken","my authorisation code");
HttpResponse response = client.execute(request);
Run Code Online (Sandbox Code Playgroud)
我也有
<permission android:name="android.permission.INTERNET"></permission>
Run Code Online (Sandbox Code Playgroud)
作为manifest.xml中的manifest(不是application)的子代
当我尝试在浏览器中打开网址时,我得到了正确的页面但我没有得到任何数据,因为它错过了身份验证.我也有很好的联系.
我一直试图解决这个问题几个小时,但我仍然在client.execute(请求)的行中获得IOException
java.net.UnknownHostException: my.server.com
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?:) 谢谢!
我的文件系统上有以下现有的目录结构(使用ext4的Ubuntu 12.04桌面):
/
home/
myuser/
.myapp/
logs/
myapp.log
data/
lib/
Run Code Online (Sandbox Code Playgroud)
...以及以下Java代码:
try {
// If no such file exists, create it and write zero (0) to it.
if(!myFile.exists()) {
System.out.println("myFile is: " + myFile.getAbsolutePath());
myFile.createNewFile();
myFileWriter.write("0"); // Configured to write to myFile
}
} catch(IOException ioExc) {
logger.error(ExceptionUtils.getStackTrace(ioExc));
throw new RuntimeException(ioExc);
}
Run Code Online (Sandbox Code Playgroud)
......抛出以下异常:
myFile is: /home/myuser/.myapp/data/replay/Loader-0-replay.log
java.lang.RuntimeException: java.io.IOException: No such file or directory
at net.myuser.myapp.tools.myapp.Loader.<init>(Loader.java:69)
at net.myuser.myapp.tools.myapp.MyAppTool.loadWords(MyAppTool.java:125)
at net.myuser.myapp.tools.myapp.MyAppTool.run(MyAppTool.java:65)
at net.myuser.myapp.tools.myapp.MyAppTool.main(MyAppTool.java:41)
Caused by: java.io.IOException: No such file or …Run Code Online (Sandbox Code Playgroud) 我试图将输入流图像写入OutputStream以在浏览器中显示图像,这是代码:
try
{
InputStream input = Filer.readImage("images/test.jpg");
byte[] buffer = new byte[1024];
int bytesRead;
while ((bytesRead = input.read(buffer)) != -1)
{
responseBody.write(buffer, 0, bytesRead);
}
}
catch(IOException e)
{
System.out.println(e);
}
Run Code Online (Sandbox Code Playgroud)
readImage:
public static InputStream readImage(String file) throws IOException {
try (InputStream input = new FileInputStream(file)) {
return input;
}
}
Run Code Online (Sandbox Code Playgroud)
但写作时我收到错误:
java.io.IOException: Stream Closed
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
任何人都可以告诉我为什么这个程序不起作用.你应该创建一个汇总双值的文件.当我运行程序时,它会读取文件但不显示总和.
import java.util.*;
import java.io.*;
public class TheGradesArrays
{
public static void main(String [] args)
{
Scanner scan = new Scanner (System.in);
Scanner infile=null;
boolean isValid;
String name;
do
{
isValid=true;
System.out.print("Enter the name of the file: ");
name=scan.nextLine();
try
{
infile = new Scanner (new FileInputStream (name+".txt"));
}
catch(IOException fe)
{
System.out.println("The name is not valid! Renter the name."+fe);
fe.printStackTrace();
isValid=false;
}
}while(! isValid );
double sum=0,grade;
while(infile.hasNextDouble());
{
grade=infile.nextDouble();
sum+=grade;
}
System.out.print("The Sum = "+sum);
}
}
Run Code Online (Sandbox Code Playgroud) Java将不会让我createNewFile,因为我想创建不存在,对此,文件咄,这就是为什么我要创建它.这是我的代码片段.
System.out.println("Please input the path of the install directory.");
System.out.print(">");
installLocation = input.nextLine();
File spreadsheet = new File (installLocation + "diatracker.csv");
File settingsFile = new File (installLocation + "settings.txt");
if ( spreadsheet.exists() )
{
if ( isValidFile ( spreadsheet.toString() ) )
{
//do nothing
}
else
{
spreadsheet.delete();
spreadsheet.createNewFile();
}
}
else
{
spreadsheet.createNewFile();
}
Run Code Online (Sandbox Code Playgroud)
这是我的错误.
请输入安装目录的路径.
C:\ Users \用户DigiDuncan \桌面\ DiaTracker \
Exception in thread "main" java.io.IOException: The system cannot find the path specified
at java.io.WinNTFileSystem.createFileExclusively(Native Method) …Run Code Online (Sandbox Code Playgroud) ioexception ×10
java ×8
android ×1
c# ×1
exception ×1
exec ×1
ext4 ×1
file ×1
file-io ×1
html ×1
http ×1
inputstream ×1
jsoup ×1
outputstream ×1
parsing ×1
runtime ×1
servlets ×1
sharpziplib ×1
shell ×1
ubuntu-12.04 ×1
unknown-host ×1