Beispiel #1
0
 public static string fileToString(PeterO.Support.File file)
 {
     PeterO.Support.WrappedInputStream input = null;
     try {
         input = new PeterO.Support.WrappedInputStream(new FileStream((file).ToString(), FileMode.Open));
         return(streamToString(input));
     } finally {
         if (input != null)
         {
             input.Close();
         }
     }
 }
Beispiel #2
0
        public static void inputStreamToFile(PeterO.Support.InputStream stream, PeterO.Support.File file)
        {
            FileStream output = null;

            try {
                output = new FileStream((file).ToString(), FileMode.Create);
                copyStream(stream, output);
            } finally {
                if (output != null)
                {
                    output.Close();
                }
            }
        }
Beispiel #3
0
        /**
         *
         * Writes a _string in UTF-8 to the specified file.
         * If the file exists, it will be overwritten
         *
         * @param s a _string to write. Illegal code unit
         * sequences are replaced with
         * with U+FFFD REPLACEMENT CHARACTER when writing to the stream.
         * @param file a filename
         * @ if the file can't be created
         * or another I/O error occurs.
         */
        public static void stringToFile(string s, PeterO.Support.File file)
        {
            Stream os = null;

            try {
                os = new FileStream((file).ToString(), FileMode.Create);
                stringToStream(s, os);
            } finally {
                if (os != null)
                {
                    os.Close();
                }
            }
        }