aboutsummaryrefslogtreecommitdiff
path: root/common/src/at/gv/egovernment/moa/util/FileUtils.java
diff options
context:
space:
mode:
author(no author) <(no author)@d688527b-c9ab-4aba-bd8d-4036d912da1d>2005-01-28 14:10:50 +0000
committer(no author) <(no author)@d688527b-c9ab-4aba-bd8d-4036d912da1d>2005-01-28 14:10:50 +0000
commit7916c117627db0411b35f202f88b2ab6e115361a (patch)
tree64d196008935d0c2913958edca0c4a8da62eec2f /common/src/at/gv/egovernment/moa/util/FileUtils.java
parentd9183e34404ab3431c94002b963985a4346cf60a (diff)
downloadmoa-id-spss-7916c117627db0411b35f202f88b2ab6e115361a.tar.gz
moa-id-spss-7916c117627db0411b35f202f88b2ab6e115361a.tar.bz2
moa-id-spss-7916c117627db0411b35f202f88b2ab6e115361a.zip
This commit was manufactured by cvs2svn to create tagtags/MOA-ID-1_20d09
'MOA-ID-1_20d09'. git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/tags/MOA-ID-1_20d09@264 d688527b-c9ab-4aba-bd8d-4036d912da1d
Diffstat (limited to 'common/src/at/gv/egovernment/moa/util/FileUtils.java')
-rw-r--r--common/src/at/gv/egovernment/moa/util/FileUtils.java112
1 files changed, 0 insertions, 112 deletions
diff --git a/common/src/at/gv/egovernment/moa/util/FileUtils.java b/common/src/at/gv/egovernment/moa/util/FileUtils.java
deleted file mode 100644
index ae8d83834..000000000
--- a/common/src/at/gv/egovernment/moa/util/FileUtils.java
+++ /dev/null
@@ -1,112 +0,0 @@
-package at.gv.egovernment.moa.util;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-
-/**
- * Utility for accessing files on the file system, and for reading from input streams.
- * @author Paul Ivancsics
- * @version $Id$
- */
-public class FileUtils {
-
- /**
- * Reads a file, given by URL, into a byte array.
- * @param urlString file URL
- * @return file content
- * @throws IOException on any exception thrown
- */
- public static byte[] readURL(String urlString) throws IOException {
- URL url = new URL(urlString);
- InputStream in = new BufferedInputStream(url.openStream());
- byte[] content = StreamUtils.readStream(in);
- in.close();
- return content;
- }
- /**
- * Reads a file, given by URL, into a String.
- * @param urlString file URL
- * @param encoding character encoding
- * @return file content
- * @throws IOException on any exception thrown
- */
- public static String readURL(String urlString, String encoding) throws IOException {
- byte[] content = readURL(urlString);
- return new String(content, encoding);
- }
- /**
- * Reads a file, given by filename, into a byte array.
- * @param filename filename
- * @return file content
- * @throws IOException on any exception thrown
- */
- public static byte[] readFile(String filename) throws IOException {
- BufferedInputStream in = new BufferedInputStream(new FileInputStream(filename));
- byte[] content = StreamUtils.readStream(in);
- in.close();
- return content;
- }
- /**
- * Reads a file, given by filename, into a String.
- * @param filename filename
- * @param encoding character encoding
- * @return file content
- * @throws IOException on any exception thrown
- */
- public static String readFile(String filename, String encoding) throws IOException {
- byte[] content = readFile(filename);
- return new String(content, encoding);
- }
- /**
- * Reads a file from a resource.
- * @param name resource name
- * @return file content as a byte array
- * @throws IOException on any exception thrown
- */
- public static byte[] readResource(String name) throws IOException {
- ClassLoader cl = FileUtils.class.getClassLoader();
- BufferedInputStream in = new BufferedInputStream(cl.getResourceAsStream(name));
- byte[] content = StreamUtils.readStream(in);
- in.close();
- return content;
- }
- /**
- * Reads a file from a resource.
- * @param name filename
- * @param encoding character encoding
- * @return file content
- * @throws IOException on any exception thrown
- */
- public static String readResource(String name, String encoding) throws IOException {
- byte[] content = readResource(name);
- return new String(content, encoding);
- }
-
- /**
- * Returns the absolute URL of a given url which is relative to the parameter root
- * @param url
- * @param root
- * @return String
- */
- public static String makeAbsoluteURL(String url, String root) {
- //if url is relative to rootConfigFileDirName make it absolute
-
- File keyFile;
- String newURL = url;
-
- if(null == url) return null;
-
- // check if absolute - if not make it absolute
- keyFile = new File(url);
- if (!keyFile.isAbsolute()) {
- keyFile = new File(root, url);
- newURL = keyFile.getPath();
- }
- return newURL;
- }
-
-}