我试图在 try with resources block 中打开 OutputStream
资源:
try (OutputStream output = connection.getOutputStream()) {
output.write(query.getBytes(charset));
}
但是,我遇到了编译错误:
Resource specification not allowed here for source level below 1.7
是否有 1.6 的等效版本,或者我是否必须将我的项目转换为 1.7?
最佳答案
试试这个代码
try {
OutputStream output = connection.getOutputStream();
output.write(query.getBytes(charset));
}catch (Exception e) {
e.printStackTrace();
}
关于java - 对于低于 1.7 的源级别,此处不允许使用资源规范,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39972926/