I try to extract a file which is attached in my "src" folder.
So I wanted to get the Inputstream from the file and write it into for example c:/file.txt
my code:
InputStream is = Main.class.getResourceAsStream("test.txt");
OutputStream os = new FileOutputStream("c:/file.txt");
byte[] buffer = new byte[4096];
int length;
while ((length = is.read(buffer)) > 0) {
os.write(buffer, 0, length);
}
os.close();
is.close();
The Error:
Type mismatch: Eclipse cannot convert from java.io.InputStream to org.omg.CORBA.portable.InputStream
Remove this import
import org.omg.CORBA.portable.InputStream;
from your class, and add
import java.io.InputStream
You imported the wrong InputStream.
Try importing java.io.InputStream instead of org.omg.CORBA.portable.InputStream.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With