@@ -819,7 +819,7 @@ public SketchSurfaceViewGL(Context context, int wide, int high, boolean is3D) {
819819 setEGLContextClientVersion (2 );
820820
821821 // The renderer can be set only once.
822- setRenderer (g3 .pgl .getRenderer ());
822+ setRenderer (PGraphicsOpenGL .pgl .getRenderer ());
823823 setRenderMode (GLSurfaceView .RENDERMODE_WHEN_DIRTY );
824824
825825 // assign this g to the PApplet
@@ -4148,6 +4148,31 @@ public void run() {
41484148
41494149
41504150
4151+ //////////////////////////////////////////////////////////////
4152+
4153+ // EXTENSIONS
4154+
4155+
4156+ /**
4157+ * Get the compression-free extension for this filename.
4158+ * @param filename The filename to check
4159+ * @return an extension, skipping past .gz if it's present
4160+ */
4161+ static public String checkExtension (String filename ) {
4162+ // Don't consider the .gz as part of the name, createInput()
4163+ // and createOuput() will take care of fixing that up.
4164+ if (filename .toLowerCase ().endsWith (".gz" )) {
4165+ filename = filename .substring (0 , filename .length () - 3 );
4166+ }
4167+ int dotIndex = filename .lastIndexOf ('.' );
4168+ if (dotIndex != -1 ) {
4169+ return filename .substring (dotIndex + 1 ).toLowerCase ();
4170+ }
4171+ return null ;
4172+ }
4173+
4174+
4175+
41514176 //////////////////////////////////////////////////////////////
41524177
41534178 // DATA I/O
@@ -4266,16 +4291,6 @@ public boolean saveTable(Table table, String filename, String options) {
42664291 }
42674292
42684293
4269- protected String checkExtension (String filename ) {
4270- int index = filename .lastIndexOf ('.' );
4271- if (index == -1 ) {
4272- return null ;
4273- }
4274- return filename .substring (index + 1 ).toLowerCase ();
4275- }
4276-
4277-
4278-
42794294
42804295 // FONT I/O
42814296
@@ -4881,6 +4896,38 @@ static public String[] loadStrings(File file) {
48814896 }
48824897
48834898
4899+ static public String [] loadStrings (BufferedReader reader ) {
4900+ try {
4901+ String lines [] = new String [100 ];
4902+ int lineCount = 0 ;
4903+ String line = null ;
4904+ while ((line = reader .readLine ()) != null ) {
4905+ if (lineCount == lines .length ) {
4906+ String temp [] = new String [lineCount << 1 ];
4907+ System .arraycopy (lines , 0 , temp , 0 , lineCount );
4908+ lines = temp ;
4909+ }
4910+ lines [lineCount ++] = line ;
4911+ }
4912+ reader .close ();
4913+
4914+ if (lineCount == lines .length ) {
4915+ return lines ;
4916+ }
4917+
4918+ // resize array to appropriate amount for these lines
4919+ String output [] = new String [lineCount ];
4920+ System .arraycopy (lines , 0 , output , 0 , lineCount );
4921+ return output ;
4922+
4923+ } catch (IOException e ) {
4924+ e .printStackTrace ();
4925+ //throw new RuntimeException("Error inside loadStrings()");
4926+ }
4927+ return null ;
4928+ }
4929+
4930+
48844931 /**
48854932 * Load data from a file and shove it into a String array.
48864933 * <P>
@@ -4985,19 +5032,19 @@ public OutputStream createOutput(String filename) {
49855032 }
49865033
49875034
4988- // static public OutputStream createOutput(File file) {
4989- // try {
4990- // FileOutputStream fos = new FileOutputStream(file);
4991- // if (file.getName().toLowerCase().endsWith(".gz")) {
4992- // return new GZIPOutputStream(fos);
4993- // }
4994- // return fos;
4995- //
4996- // } catch (IOException e) {
4997- // e.printStackTrace();
4998- // }
4999- // return null;
5000- // }
5035+ static public OutputStream createOutput (File file ) {
5036+ try {
5037+ FileOutputStream fos = new FileOutputStream (file );
5038+ if (file .getName ().toLowerCase ().endsWith (".gz" )) {
5039+ return new GZIPOutputStream (fos );
5040+ }
5041+ return fos ;
5042+
5043+ } catch (IOException e ) {
5044+ e .printStackTrace ();
5045+ }
5046+ return null ;
5047+ }
50015048
50025049
50035050 /**
0 commit comments