File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed
examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change 24
24
*/
25
25
import java .io .*;
26
26
import java .lang .reflect .*;
27
+ import java .nio .charset .*;
28
+ import java .nio .file .*;
27
29
28
30
import org .eclipse .swt .*;
29
31
@@ -47,15 +49,13 @@ public static void main (String [] args) {
47
49
if (clazz != null ) {
48
50
System .out .println ("\n " + clazz .getName ());
49
51
if (hasSource ) {
50
- File sourceFile = new File (sourceDir , className + ".java" );
51
- try (FileReader reader = new FileReader (sourceFile );){
52
- char [] buffer = new char [(int )sourceFile .length ()];
53
- reader .read (buffer );
54
- String source = String .valueOf (buffer );
52
+ Path sourceFile = Path .of (sourceDir .getPath (), className + ".java" );
53
+ try {
54
+ String source = Files .readString (sourceFile , StandardCharsets .UTF_8 );
55
55
int start = source .indexOf ("package" );
56
56
start = source .indexOf ("/*" , start );
57
57
int end = source .indexOf ("* For a list of all" );
58
- System .out .println (source .substring (start , end -3 ));
58
+ System .out .println (source .substring (start + 3 , end -3 ));
59
59
boolean skip = false ;
60
60
String platform = SWT .getPlatform ();
61
61
if (source .contains ("OpenGL" )) {
You can’t perform that action at this time.
0 commit comments