/**
* GmailAssistant 1.1 (2008-03-16)
* Copyright 2008 Zach Scrivena
* zachscrivena@gmail.com
* http://gmailassistant.sourceforge.net/
*
* Notifier for multiple Gmail accounts.
*
* TERMS AND CONDITIONS:
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gmailassistant;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
* Perform miscellaneous resource manipulation tasks.
*/
class ResourceManipulator
{
/**
* Return the contents of the specified resource as a string.
*
* @param name
* name of the resource
* @return
* contents of the resource as a string
* @throws java.io.IOException
* if an I/O error occurs while reading the resource
*/
static String resourceAsString(
final String name)
throws IOException
{
final BufferedReader br = new BufferedReader(new InputStreamReader(
ResourceManipulator.class.getResourceAsStream(name)));
final StringBuilder sb = new StringBuilder();
while (true)
{
final String s = br.readLine();
if (s == null)
{
break;
}
else
{
if (sb.length() > 0)
{
sb.append('\n');
}
sb.append(s);
}
}
br.close();
return sb.toString();
}
}