Skip to content

Commit

Permalink
clarified stream closing in javadoc, initial capacity for StringBuilder.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbien committed May 18, 2011
1 parent f12e3a9 commit dcf8396
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/com/jogamp/opencl/CLContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ private static NativeSizeBuffer setupContextProperties(CLPlatform platform) {
}

/**
* Creates a program from the given sources, the program is not build yet.
* Creates a program from the given sources, the returned program is not build yet.
*/
public CLProgram createProgram(String src) {
CLProgram program = CLProgram.create(this, src);
Expand All @@ -251,7 +251,8 @@ public CLProgram createProgram(String src) {
}

/**
* Creates a program and reads the source from stream, the program is not build yet.
* Creates a program and reads the source from stream, the returned program is not build yet.
* The InputStream is automatically closed after the sources have been read.
* @throws IOException when a IOException occurred while reading or closing the stream.
*/
public CLProgram createProgram(InputStream source) throws IOException {
Expand All @@ -260,14 +261,14 @@ public CLProgram createProgram(InputStream source) throws IOException {
throw new IllegalArgumentException("input stream for program source must not be null");

BufferedReader reader = new BufferedReader(new InputStreamReader(source));
StringBuilder sb = new StringBuilder();
StringBuilder sb = new StringBuilder(2048);

String line;
try {
while ((line = reader.readLine()) != null)
sb.append(line).append("\n");
} finally {
source.close();
reader.close();
}

return createProgram(sb.toString());
Expand Down

0 comments on commit dcf8396

Please sign in to comment.