Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do I need manually call close()? #136

Closed
xxxifan opened this issue Apr 1, 2015 · 1 comment
Closed

Do I need manually call close()? #136

xxxifan opened this issue Apr 1, 2015 · 1 comment

Comments

@xxxifan
Copy link

xxxifan commented Apr 1, 2015

Do I need manually call close() like this?

    // Read inputStream and output to temFile path
    Source source = Okio.source(inputStream); 
    BufferedSource buffer = Okio.buffer(source);
    Sink sink = Okio.sink(tmpFile);
    buffer.readAll(sink); 

    sink.close();
    buffer.close();
    source.close();
@JakeWharton
Copy link
Member

Calling buffer.close() will automatically call source.close(). Otherwise, yes, you should close both the source and sink to ensure any resources are released when you are done with the objects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants