天道酬勤,学无止境

ioexception

java.io.IOException: No space left on device Android

We have application on android market, our users getting a lot from this error: java.io.IOException: No space left on device From what I found out so far, I know that they got enough space left on they external storage, and it's only happen on Android 2.x . I had a small research in Linux file system, and I found out that beyond the space limitation there are limitation on number of files in each directory and the total number of files under root directory. But it looks like our app is not hitting any of those. Have you ever run in two some thing like that? Any ideas about what changed in

2021-06-14 08:55:44    分类:问答    java   android   io   filesystems   ioexception

How to distinguish programmatically between different IOExceptions?

I am doing some exception handling for code which is writing to the StandardInput stream of a Process object. The Process is kind of like the unix head command; it reads only part of it's input stream. When the process dies, the writing thread fails with: IOException The pipe has been ended. (Exception from HRESULT: 0x8007006D) I would like to catch this exception and let it fail gracefully, since this is expected behavior. However, it's not obvious to me how this can robustly be distinguished from other IOExceptions. I could use message, but it's my understanding that these are localized and

2021-06-14 00:08:14    分类:问答    c#   exception-handling   ioexception   hresult

Android (Write on external SD-Card): java.io.IOException: Permission denied

I get a "Permission denied" error, when I want to create a file on my external SD-Card (named /storage/B9BE-18A6). I know that you have to ask for the write permission programmatically since Android M. So I inserted the solution from Arpit Patel (Android 6.0 Marshmallow. Cannot write to SD Card) I don't know why I still haven't the permissions to do it. Do you guys have another solution that I can create files on my SD-Card? Code for creating the file FloatingActionButton fab_new_file = (FloatingActionButton) rLayoutFrgEmpresas.findViewById(R.id.fab_menu_item_file); fab_new_file

2021-06-13 02:37:23    分类:问答    android   android-6.0-marshmallow   android-sdcard   ioexception   permission-denied

使用 Scanner 读取输入会导致 Java 中的无限循环 [重复](Reading input using Scanner causes an infinite loop in Java [duplicate])

问题 这个问题在这里已经有了答案: 如何使用扫描仪处理由无效输入 (InputMismatchException) 引起的无限循环(5 个回答) 3年前关闭。 在我的程序中,我试图让用户输入 1-3 之间的 int,然后根据他们输入的内容执行某些操作。 如果它不是数字或不是选项之一,那么它将允许他们重新输入有效选项。 我遇到的问题是我无法集思广益如何不让它无限循环,只允许他们在控制台告诉他们输入无效输入后输入一个数字。 int i = 0; while (i < 1) { try { int level = scan.nextInt(); i+=1; if (level == 1) { System.out.println("You selected level 1!"); //Start the game } else if (level == 2) { System.out.println("You selected level 2!"); //Start the game } else if (level == 3) { System.out.println("You selected level 3!"); //Start the game } else { System.out.println("That's not an option!"); i-=1; } }

2021-06-12 17:43:27    分类:技术分享    java   while-loop   infinite-loop   ioexception

Java:BufferedReader 的 readLine() 中的 IOEXceptions 有什么用?(Java: what are IOEXceptions in BufferedReader's readLine() for?)

问题 我可以使用 try-catch 循环“修复”以下异常,但我无法理解原因。 为什么“in.readLine()”部分会持续引发 IOExceptions? 抛出这种异常的真正目的是什么,目标可能不仅仅是更多的副作用? 代码和 IOExceptions $ javac ReadLineTest.java ReadLineTest.java:9: unreported exception java.io.IOException; must be caught or declared to be thrown while((s=in.readLine())!=null){ ^ 1 error $ cat ReadLineTest.java import java.io.*; import java.util.*; public class ReadLineTest { public static void main(String[] args) { String s; BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); // WHY IOException here? while((s=in.readLine())!=null){ System.out.println(s); } } }

2021-06-12 16:00:33    分类:技术分享    java   exception   ioexception

在文件读取期间强制 IOException(Force IOException during file reading)

问题 我有一段从文件中读取数据的代码。 我想在此代码中强制 IOException 用于测试目的(我想检查代码在这种情况下是否抛出正确的自定义异常)。 例如,有什么方法可以创建一个防止被读取的文件? 也许处理一些安全检查会有所帮助? 请注意,传递不存在文件的名称无济于事,因为 FileNotFoundException 有一个单独的 catch 子句。 下面是一段代码,可以更好地理解这个问题: BufferedReader reader = null; try { reader = new BufferedReader(new FileReader(csvFile)); String rawLine; while ((rawLine = reader.readLine()) != null) { // some work is done here } } catch (FileNotFoundException e) { throw new SomeCustomException(); } catch (IOException e) { throw new SomeCustomException(); } finally { // close the input stream if (reader != null) { try { reader.close(); } catch

2021-06-12 11:09:42    分类:技术分享    java   junit   ioexception

反序列化问题 - java.io.StreamCorruptedException:无效类型代码:00(Deserialisation issue - java.io.StreamCorruptedException: invalid type code: 00)

问题 我正在编写一个 java 文件传输应用程序,我在反序列化自己定义的类 Message from Datagramms 时遇到了一些麻烦。 StackOverflow 上的其他主题也有类似的问题,但我没有从那里找到有用的东西,所以如果我错过了,我提前道歉。 所以,类消息是: import java.io.Serializable; public class Message implements Serializable { private static final long serialVersionUID = 1L; private int segmentID; private byte[] packet; private int bytesToWrite; public Message(){ segmentID = -1; } public Message(int segmentID, byte[] packet, int bytesToWrite) { this.segmentID = segmentID; this.packet = packet; this.bytesToWrite = bytesToWrite; } public int getBytesToWrite() { return bytesToWrite; } public int

2021-06-11 21:33:20    分类:技术分享    java   serialization   deserialization   ioexception   corruption

Error while playing some MP3s using JavaZOOM BasicPlayer classes

Here is the stack trace: java.io.IOException: Resetting to invalid mark at java.io.BufferedInputStream.reset(BufferedInputStream.java:433) at org.tritonus.share.sampled.file.TAudioFileReader.getAudioInputStream(TAudioFileReader.java:324) at javazoom.spi.mpeg.sampled.file.MpegAudioFileReader.getAudioInputStream(Unknown Source) at javazoom.spi.mpeg.sampled.file.MpegAudioFileReader.getAudioInputStream(Unknown Source) at javax.sound.sampled.AudioSystem.getAudioInputStream(AudioSystem.java:1179) at javazoom.jlgui.basicplayer.BasicPlayer.initAudioInputStream(Unknown Source) at javazoom.jlgui

2021-06-11 20:39:30    分类:问答    java   swing   mp3   ioexception   javasound

Parceable encountered IOException writing serializable object

I am getting this error : FATAL EXCEPTION: main java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = game.Level) at android.os.Parcel.writeSerializable(Parcel.java) at android.os.Parcel.writeValue(Parcel.java) at android.os.Parcel.writeMapInternal(Parcel.java) at android.os.Bundle.writeToParcel(Bundle.java) at android.os.Parcel.writeBundle(Parcel.java) at android.content.Intent.writeToParcel(Intent.java) at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java) at android.app.Instrumentation.execStartActivity(Instrumentation

2021-06-11 18:16:00    分类:问答    android   ioexception   parcelable   serializable

Android nfcv.transceive() throws an exception

I wrote an Android app that uses the transceive() function to communicate with an NFC-V card. My problem is that line byte[] response = nfcv.transceive(command) always throws a tag lost exception. Could someone help me? String action = intent.getAction(); Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG); NfcV nfcv = NfcV.get(tag); if(nfcv != null) { Toast.makeText(this, "nfcv detected", Toast.LENGTH_LONG).show(); } try { nfcv.connect(); Toast.makeText(this, "connected", Toast.LENGTH_LONG).show(); byte[] command = new byte[]{ (byte) 0x00, // Flags (byte) 0x20, // Command: Read single

2021-06-11 14:02:23    分类:问答    android   nfc   ioexception   iso-15693