Skip to content

Tag: io

How to use SequenceInputStream?

🍳Background 1.I was learning the basic grammar of input and output in java. 2.But I found that the SequenceInputStream worked strangely. ⚡Code ⚡outcome 🔑Question 1.Why did the method(read) stop when meet EOF? 2.How to read the next Stream? Answer Why did the method(read) stop when meet EOF? You might be expec…

How can I remove last 2 lines in text file in Java?

I want remove last 2 lines in my text file using java. I tried 4 or 5 different ways about this, but I can’t find working code. I will edit file like this: I want delete “]” , “}” and add “example2”. How can I do that ? (I’m using SE 1.8 , maybe version have an …

How to perform unbuffered input in Java (if at all possible)?

Java Beginner here. When we input a string, we have to press the enter key to let the program know that the user has done inputting. Is there a way where we use another key instead of enter key (for example a question mark key) to input a string? Answer Ever heard of something called a “buffer”? I…

get removable sd card path in android

How can i get extSdcard path in android? There are 2 storage, first external storage in which all the phones have it but there is second storage which is called removable storage (micro sdcard). I want to get the path to the micro sdcard in android, how is that possible? Answer Starting from KitKat, you have …

Code in “catch” block not executing

please help me understand why:) My program reach the “try” line, but seems to skip the “catch”, Although its printing the stacktrace… I’m using JOptionPane in my catch, but also System.out.println() not working. Code: Exception: Answer There is an NullPointerException inter…