Aur*_*rus 2 java inputstream outputstream
我尝试提取一个附加在我的"src"文件夹中的文件.
所以我想从File获取Inputstream并将其写入例如c:/file.txt
我的代码:
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();
Run Code Online (Sandbox Code Playgroud)
错误:
" Type mismatch: Eclipse cannot convert from java.io.InputStream to
org.omg.CORBA.portable.InputStream "
Run Code Online (Sandbox Code Playgroud)
谢谢
删除此导入
import org.omg.CORBA.portable.InputStream;
Run Code Online (Sandbox Code Playgroud)
从你的班级,并添加
import java.io.InputStream
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3113 次 |
| 最近记录: |