Open the provided filename as an outputstream.

@param fileName
@return OutputStream
@throws MalformedURLException
@throws IOException
197748
public OutputStream getOutputStream(String fileName) throws MalformedURLException, IOException {
        try {
            GetKeyStoreOutputStreamAction action = new GetKeyStoreOutputStreamAction(fileName);
            return AccessController.doPrivileged(action);
        } catch (PrivilegedActionException e) {
            Exception ex = e.getException();
            FFDCFilter.processException(e, getClass().getName(), "getOutputStream", new Object[] { fileName, this });
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                Tr.debug(tc, "Exception opening keystore; " + ex);

            if (ex instanceof MalformedURLException)
                throw (MalformedURLException) ex;
            else if (ex instanceof IOException)
                throw (IOException) ex;

            throw new IOException(ex.getMessage());
        }
    }
1060977
public static InputStream openKeyStore(String fileName) throws MalformedURLException, IOException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            Tr.entry(tc, "openKeyStore: " + fileName);

        URL urlFile = null;

        // Check if the filename exists as a File.
        File kfile = new File(fileName);

        if (kfile.exists() && kfile.length() == 0) {
            throw new IOException("Keystore file exists, but is empty: " + fileName);
        } else if (!kfile.exists()) {
            urlFile = new URL(fileName);
        } else {
            // kfile exists
            urlFile = new URL("file:" + kfile.getCanonicalPath());
        }

        // Finally open the file.
        InputStream fis = urlFile.openStream();

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            Tr.exit(tc, "openKeyStore: " + (null != fis));
        return fis;
    }
75306
public static String loadFile(String filename) {
        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        InputStream is = classLoader.getResourceAsStream(filename);
        if (is == null) {
            throw new IllegalArgumentException("Unable to locate: " + filename);
        }
        return streamToString(is, filename);
    }
535050
public File pathToFile( String fileName )
        throws IOException
    {
        String cwd = (String)getu("bsh.cwd");
        File file = new File( fileName );

        // if relative, fix up to bsh.cwd
        if ( !file.isAbsolute() ) {
            file = new File( cwd + File.separator + fileName );
        }

        return new File( file.getCanonicalPath() );
    }
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;
	}
130768
public static String readFile( String name ) throws IOException {
        StringBuilder b = new StringBuilder();
        BufferedReader r = new BufferedReader(new FileReader(name));
        String line;
        while( (line = r.readLine()) != null ) {
            b.append(line).append('\n');
        }
        r.close();
        return b.toString();
    }
971927
public InputStream loadTemplate(String fileName) throws IOException {
	Path currentPath=new Path(fileName);
	return openFile(currentPath);
}
1269884
public static URL toURL(String filename) throws MalformedURLException {
        try {
            return new URL(filename);
        }
        catch (Exception e) {
            return new File(filename).toURI().toURL();
        }
	}
688894
public StreamOut createFile(String strFullFileName)
    {
        StreamOut streamOut = null;
        try   {
            File file = new File(strFullFileName);
            String pathName = file.getParent();
            File fileDir = new File(pathName);
            fileDir.mkdirs();
            streamOut = new StreamOut(strFullFileName);
        } catch (IOException ex)    {
            ex.printStackTrace();
            streamOut = null;
        }
        return streamOut;
    }
259205
public static byte[] readFile (String fileName) throws OSHelperException {
		File file = new File (fileName);
		if (!file.exists ()) {
			throw new OSHelperException ("File " + fileName + " does not exist");
		}
		if (!file.canRead ()) {
			throw new OSHelperException ("File " + fileName + " is not readable");
		}
		if (!file.isFile ()) {
			throw new OSHelperException ("File " + fileName + " is not a normal file");
		}

		RandomAccessFile raFile = null;
		try {
			raFile = new RandomAccessFile (fileName, "r");
		} catch (FileNotFoundException ex) {
			throw new OSHelperException ("File " + fileName + " not found");
		}

		long fileLengthLong;
		try {
			fileLengthLong = raFile.length ();
		} catch (IOException ex) {
			throw new OSHelperException (ex);
		}
		if (fileLengthLong > Integer.MAX_VALUE) {
			throw new OSHelperException ("File length exceeds " + Integer.MAX_VALUE + " bytes: " + fileLengthLong);
		}

		int fileLengthInt = (int) fileLengthLong;

		byte[] bytes = new byte[fileLengthInt];
		try {
			raFile.read (bytes);
		} catch (IOException ex) {
			throw new OSHelperException (ex);
		} finally {
			try {
				raFile.close ();
			} catch (IOException ex) {
				throw new OSHelperException (ex);
			}
		}

		return bytes;
	}
1367632
public void readFile(String filename) throws ConverterException {
        try {
            content = "";
            final InputStream input = ResourceManager.getInputStream(filename);
            while (input.available() > 0) {
                content = content + (char) input.read();
            }
            input.close();
        } catch (Exception e) {
            throw new ConverterException(e);
        }
    }
462567
public static InputStream getResourceAsStream(String fileName) throws FileNotFoundException {
    String localPath = UI_DIR + fileName;
    String altLocalPath = INTERNAL_BUILD_UI_DIR + fileName;
    InputStream in = StaticContentHandler.class.getResourceAsStream(localPath);
    if (in == null) {
      in = StaticContentHandler.class.getResourceAsStream(altLocalPath);
    }
    if (in == null) {
      throw new FileNotFoundException(localPath + " <or> " + altLocalPath);
    }
    return in;
  }
61966
public static String getURL(final String fileName) {

        if (fileName.startsWith("file:/")) {
            return fileName;
        } else {
            final File file = new File(fileName);
            return file.toURI().toString();
        }

    }
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;
    }
1191908
private void openInputFile(final String inputFileName) throws IOException
	{
		myInputFile = new File(inputFileName);
		myInputStream = new FileInputStream(myInputFile);
		myStreamReader = new InputStreamReader(myInputStream, getInputEncodingCode());
		myBufferedReader = new BufferedReader(myStreamReader);
		myLineReader = new LineNumberReader(myBufferedReader);
	}
901610
public static File fileFromString(String fileName) {
        try {
            return new File(new URI(fileName).getPath());
        } catch (URISyntaxException ex ) {
            // Not a valid uri
            return new File(fileName);
        }
    }
10636
private function openStream($filename)
    {
        if (!file_exists($filename)) {
            throw new ExtensionException(sprintf('File path (%s) doesn\'t exist', $filename));
        }
        
        if (!is_readable($filename)) {
            throw new ExtensionException(sprintf('File path (%s) doesn\'t readable', $filename));
        }
        
        return fopen($filename, 'a+');
    }