Glyn
Glyn

Reputation: 2005

Resource specification not allowed here for source level below 1.7

I am trying to open an OutputStream resource in a try with resources block:

try (OutputStream output = connection.getOutputStream()) {
    output.write(query.getBytes(charset));
}

However, I got a compilation error:

Resource specification not allowed here for source level below 1.7

Is there an equivalent for 1.6 or do I have to convert my project to 1.7?

Upvotes: 2

Views: 3061

Answers (1)

Bhaskara Arani
Bhaskara Arani

Reputation: 1667

try this code

try {
    OutputStream output = connection.getOutputStream();
    output.write(query.getBytes(charset));
}catch (Exception e) {
    e.printStackTrace();
}

Upvotes: 2

Related Questions