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 2424 */
2525import java .io .*;
2626import java .lang .reflect .*;
27+ import java .nio .charset .*;
28+ import java .nio .file .*;
2729
2830import org .eclipse .swt .*;
2931
@@ -47,15 +49,13 @@ public static void main (String [] args) {
4749 if (clazz != null ) {
4850 System .out .println ("\n " + clazz .getName ());
4951 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 );
5555 int start = source .indexOf ("package" );
5656 start = source .indexOf ("/*" , start );
5757 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 ));
5959 boolean skip = false ;
6060 String platform = SWT .getPlatform ();
6161 if (source .contains ("OpenGL" )) {
You can’t perform that action at this time.
0 commit comments