A helper method to get a PCM (share the limitation of _loadPCMContainter)
@param filename
@return
@throws IOException
19263
public static PCM loadPCM(String filename) throws IOException {

        PCMContainer pcmContainer = loadPCMContainer(filename);
        // Get the PCM
        PCM pcm = pcmContainer.getPcm();

        return pcm ;
    }
902438
public static Bitmap loadBitmapOptimized(String fileName, int limit) throws ImageLoadException {
        return loadBitmapOptimized(new FileSource(fileName), limit);
    }
656096
private void readPCM() throws IOException {
        boolean wrote = false;

        while (true) { // we repeat if the bitstream is chained
            if (endOfBitStream) {
                if (!getPageAndPacket()) {
                    break;
                }
                endOfBitStream = false;
            }

            if (!inited) {
                inited = true;
                return;
            }

            float[][][] _pcm = new float[1][][];
            int[] _index = new int[oggInfo.channels];
            // The rest is just a straight decode loop until end of stream
            while (!endOfBitStream) {
                while (!endOfBitStream) {
                    int result = syncState.pageout(page);

                    if (result == 0) {
                        break; // need more data
                    }

                    if (result == -1) { // missing or corrupt data at this page position
                        logger.log(Level.WARNING, "Corrupt or missing data in bitstream; continuing...");
                    } else {
                        streamState.pagein(page); // can safely ignore errors at
                        // this point
                        while (true) {
                            result = streamState.packetout(packet);

                            if (result == 0) {
                                break; // need more data
                            }
                            if (result == -1) { // missing or corrupt data at this page position
                                // no reason to complain; already complained above
                            } else {
                                // we have a packet.  Decode it
                                int samples;
                                if (vorbisBlock.synthesis(packet) == 0) { // test for success!
                                    dspState.synthesis_blockin(vorbisBlock);
                                }

								// **pcm is a multichannel float vector.  In stereo, for
                                // example, pcm[0] is left, and pcm[1] is right.  samples is
                                // the size of each channel.  Convert the float values
                                // (-1.<=range<=1.) to whatever PCM format and write it out
                                while ((samples = dspState.synthesis_pcmout(_pcm,
                                        _index)) > 0) {
                                    float[][] pcm = _pcm[0];
                                    //boolean clipflag = false;
                                    int bout = (samples < convsize ? samples
                                            : convsize);

									// convert floats to 16 bit signed ints (host order) and
                                    // interleave
                                    for (int i = 0; i < oggInfo.channels; i++) {
                                        int ptr = i * 2;
                                        //int ptr=i;
                                        int mono = _index[i];
                                        for (int j = 0; j < bout; j++) {
                                            int val = (int) (pcm[i][mono + j] * 32767.);
                                            // might as well guard against clipping
                                            if (val > 32767) {
                                                val = 32767;
                                            }
                                            if (val < -32768) {
                                                val = -32768;
                                            }
                                            if (val < 0) {
                                                val = val | 0x8000;
                                            }

                                            if (bigEndian) {
                                                convbuffer[ptr] = (byte) (val >>> 8);
                                                convbuffer[ptr + 1] = (byte) (val);
                                            } else {
                                                convbuffer[ptr] = (byte) (val);
                                                convbuffer[ptr + 1] = (byte) (val >>> 8);
                                            }
                                            ptr += 2 * (oggInfo.channels);
                                        }
                                    }

                                    int bytesToWrite = 2 * oggInfo.channels * bout;
                                    if (bytesToWrite >= pcmBuffer.remaining()) {
                                        logger.log(Level.WARNING, "Read block from OGG that was too big to be buffered: {0}", bytesToWrite);
                                    } else {
                                        pcmBuffer.put(convbuffer, 0, bytesToWrite);
                                    }

                                    wrote = true;
                                    dspState.synthesis_read(bout); // tell libvorbis how
                                    // many samples we
                                    // actually consumed
                                }
                            }
                        }
                        if (page.eos() != 0) {
                            endOfBitStream = true;
                        }

                        if ((!endOfBitStream) && (wrote)) {
                            return;
                        }
                    }
                }

                if (!endOfBitStream) {
                    bytes = 0;
                    int index = syncState.buffer(4096);
                    if (index >= 0) {
                        buffer = syncState.data;
                        try {
                            bytes = input.read(buffer, index, 4096);
                        } catch (Exception e) {
                            logger.log(Level.WARNING, "Failure during vorbis decoding", e);
                            endOfStream = true;
                            return;
                        }
                    } else {
                        bytes = 0;
                    }
                    syncState.wrote(bytes);
                    if (bytes == 0) {
                        endOfBitStream = true;
                    }
                }
            }

			// clean up this logical bitstream; before exit we see if we're
            // followed by another [chained]
            streamState.clear();

			// ogg_page and ogg_packet structs always point to storage in
            // libvorbis.  They're never freed or manipulated directly
            vorbisBlock.clear();
            dspState.clear();
            oggInfo.clear(); // must be called last
        }

        // OK, clean up the framer
        syncState.clear();
        endOfStream = true;
    }
1170380
public T loadCSV( String fileName )
            throws IOException {
        DMatrix mat = MatrixIO.loadCSV(fileName,true);

        T ret = createMatrix(1,1, mat.getType());

        ret.setMatrix(mat);

        return ret;
    }
395272
public static Bitmap loadBitmap(String fileName, int scale) throws ImageLoadException {
        return loadBitmap(new FileSource(fileName), scale);
    }
237772
public StringBuffer readFile(String filename) throws IOException {
		BufferedReader reader = new BufferedReader(new FileReader(filename));
		StringBuffer xml = new StringBuffer();
		String line = null;
        while((line = reader.readLine()) != null){
            xml.append(line);
        }
		reader.close();
		return xml;
	}
1073242
public static InputStream getFileInputStream(String filename) throws IOException {
    InputStream in = new FileInputStream(filename);
    if (filename.endsWith(".gz")) {
      in = new GZIPInputStream(in);
    } else if (filename.endsWith(".bz2")) {
      //in = new CBZip2InputStream(in);
      in = getBZip2PipedInputStream(filename);
    }
    return in;
  }
699823
@SuppressWarnings("resource")
    public InputStream getInputStream(String filename)
    {
        InputStream streamIn = null;
        if (filename.indexOf(':') == -1)
        {
            String filepath = ((BaseHttpTask)this.getTask()).getRealPath(this.getServletRequest(), filename);
            if (filepath != null)
            {
	            File file = new File(filepath);
	            try   {
	                streamIn = new FileInputStream(file);
	            } catch (FileNotFoundException ex)  {
	                streamIn = null;
	            }
            }
        }
        if (streamIn == null)
            streamIn = Utility.getInputStream(filename, this.getApplication());
        return streamIn;
    }
1276266
public static List<PCMContainer> loadCSV(File file) throws IOException {

       return loadCSV(file, PCMDirection.PRODUCTS_AS_LINES);
    }
1371963
public static File createFile(String filename) throws IOException {
		File file = new File(filename);
		if (!file.exists()) {
			if(file.getParent() != null) {
				File path = new File(file.getParent());
				path.mkdirs();
			}
			file.createNewFile();
		}
		return file;
	}
1288565
public final String loadString(final String pFileName)
        throws IOException {
    URL urlFile = SrvLedger.class
      .getResource(pFileName);
    if (urlFile != null) {
      InputStream inputStream = null;
      try {
        inputStream = SrvLedger.class.getResourceAsStream(pFileName);
        byte[] bArray = new byte[inputStream.available()];
        inputStream.read(bArray, 0, inputStream.available());
        return new String(bArray, "UTF-8");
      } finally {
        if (inputStream != null) {
          inputStream.close();
        }
      }
    }
    return null;
  }
647703
public long size(String fileName) {
		try {
			IoChannel fileChannel = getFileChannel(fileName);
			return fileChannel.size() / BLOCK_SIZE;
		} catch (IOException e) {
			throw new RuntimeException("cannot access " + fileName);
		}
	}
1285093
public static InputStream loadFile(String fileName) {
        logger.entering(fileName);
        ClassLoader loader = Thread.currentThread().getContextClassLoader();
        InputStream iStream = loader.getResourceAsStream(fileName);
        if (iStream == null) {
            try {
                iStream = new FileInputStream(fileName);
            } catch (FileNotFoundException e) { // NOSONAR
                // Gobbling the checked exception here and doing nothing with it
                // because we are explicitly checking if the inputstream is null
                // and then throwing a runtime exception
            }
        }
        if (iStream == null) {
            throw new IllegalArgumentException("[" + fileName + "] is not a valid resource");
        }
        logger.exiting();
        return iStream;
    }
258097
private static String readFile(final String fileName) throws IOException {
    return new String(Files.readAllBytes(Paths.get(fileName)), StandardCharsets.UTF_8);
  }
1267287
public static Image getInstance(String filename)
			throws BadElementException, MalformedURLException, IOException {
		return getInstance(Utilities.toURL(filename));
	}
34932
public void loadPCAFromFile(String PCAFileName) throws Exception {
		// parse the PCA projection file and put the PCA components in a 2-d double array
		BufferedReader in = new BufferedReader(new FileReader(PCAFileName));
		String line = "";

		// parse the first line which contains the training sample means
		line = in.readLine();
		String[] meanString = line.trim().split(" ");
		if (meanString.length != sampleSize) {
			throw new Exception("Means line is wrong!");
		}
		means = new DenseMatrix64F(sampleSize, 1);
		for (int j = 0; j < sampleSize; j++) {
			means.set(j, Double.parseDouble(meanString[j]));
		}

		// parse the first line which contains the eigenvalues and initialize the diagonal eigenvalue matrix W
		line = in.readLine();
		if (doWhitening) {
			String[] eigenvaluesString = line.trim().split(" ");
			if (eigenvaluesString.length < numComponents) {
				throw new Exception("Eigenvalues line is wrong!");
			}
			W = new DenseMatrix64F(numComponents, numComponents);
			for (int i = 0; i < numComponents; i++) {
				// transform the eigenValues
				double eigenvalue = Double.parseDouble(eigenvaluesString[i]);
				eigenvalue = Math.pow(eigenvalue, -0.5);
				W.set(i, i, eigenvalue);
			}
		}

		V_t = new DenseMatrix64F(numComponents, sampleSize);
		for (int i = 0; i < numComponents; i++) {
			if (i % 100 == 0) {
				System.out.println(i + " PCA components loaded.");
			}
			try {
				line = in.readLine();
			} catch (IOException e) {
				throw new Exception(
						"Check whether the given PCA matrix contains the correct number of components!");
			}
			String[] componentString = line.trim().split(" ");
			for (int j = 0; j < sampleSize; j++) {
				double componentElement = Double.parseDouble(componentString[j]);
				V_t.set(i, j, componentElement);
			}
		}

		// if whitening is true then whiten the PCA matrix V_t by multiplying it with W
		if (doWhitening) {
			System.out.print("Whitening the PCA matrix..");
			DenseMatrix64F V_t_w = new DenseMatrix64F(numComponents, sampleSize);
			CommonOps.mult(W, V_t, V_t_w);
			V_t = V_t_w;
		}

		in.close();

		isPcaInitialized = true;
	}
521082
private static String readFile(String filename)
                    throws	FileNotFoundException,
                            SecurityException,
                            IOException
    {
        FileInputStream	fid = new FileInputStream(filename);
        int nb = fid.available();
        byte[]	inStr  = new byte[nb];
        nb = fid.read(inStr);
        fid.close();
        return new String(inStr);
    }