本文整理了Java中com.sun.enterprise.util.io.FileUtils.readSmallFile()
方法的一些代码示例,展示了FileUtils.readSmallFile()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtils.readSmallFile()
方法的具体详情如下:
包路径:com.sun.enterprise.util.io.FileUtils
类名称:FileUtils
方法名:readSmallFile
[英]A utility routine to read a text file efficiently and return the contents as a String. Sometimes while reading log files of spawned processes this kind of facility is handy. Instead of opening files, coding FileReaders etc. this method could be employed. It is expected that the file to be read is small
.
[中]
代码示例来源:origin: org.glassfish.main.common/common-util
/** A utility routine to read a <b> text file </b> efficiently and return
* the contents as a String. Sometimes while reading log files of spawned
* processes this kind of facility is handy. Instead of opening files, coding
* FileReaders etc. this method could be employed. It is expected that the
* file to be read is <code> small </code>.
* @param fileName String representing absolute path of the file
* @return String representing the contents of the file, empty String for an empty file
* @throws java.io.IOException if there is an i/o error.
* @throws java.io.FileNotFoundException if the file could not be found
*/
public static String readSmallFile(final String fileName)
throws IOException, FileNotFoundException {
return (readSmallFile(new File(fileName)) );
}
代码示例来源:origin: org.glassfish.common/common-util
/** A utility routine to read a <b> text file </b> efficiently and return
* the contents as a String. Sometimes while reading log files of spawned
* processes this kind of facility is handy. Instead of opening files, coding
* FileReaders etc. this method could be employed. It is expected that the
* file to be read is <code> small </code>.
* @param fileName String representing absolute path of the file
* @return String representing the contents of the file, empty String for an empty file
* @throws java.io.IOException if there is an i/o error.
* @throws java.io.FileNotFoundException if the file could not be found
*/
public static String readSmallFile(final String fileName)
throws IOException, FileNotFoundException {
return (readSmallFile(new File(fileName)) );
}
代码示例来源:origin: eclipse-ee4j/glassfish
/** A utility routine to read a <b> text file </b> efficiently and return
* the contents as a String. Sometimes while reading log files of spawned
* processes this kind of facility is handy. Instead of opening files, coding
* FileReaders etc. this method could be employed. It is expected that the
* file to be read is <code> small </code>.
* @param fileName String representing absolute path of the file
* @return String representing the contents of the file, empty String for an empty file
* @throws java.io.IOException if there is an i/o error.
* @throws java.io.FileNotFoundException if the file could not be found
*/
public static String readSmallFile(final String fileName)
throws IOException, FileNotFoundException {
return (readSmallFile(new File(fileName)) );
}
代码示例来源:origin: org.glassfish.main.admin/server-mgmt
protected final int getPrevPid() {
try {
File prevPidFile = new File(getServerDirs().getPidFile().getPath() + ".prev");
if (!prevPidFile.canRead())
return -1;
String pids = FileUtils.readSmallFile(prevPidFile).trim();
return Integer.parseInt(pids);
}
catch (Exception ex) {
return -1;
}
}
代码示例来源:origin: org.glassfish.admin/admin-cli
protected final int getPrevPid() {
try {
File prevPidFile = new File(getServerDirs().getPidFile().getPath() + ".prev");
if (!prevPidFile.canRead())
return -1;
String pids = FileUtils.readSmallFile(prevPidFile).trim();
return Integer.parseInt(pids);
}
catch (Exception ex) {
return -1;
}
}
代码示例来源:origin: org.glassfish.main.cluster/cluster-ssh
/**
* Simple method to validate an encrypted key file
* @return true|false
* @throws CommandException
*/
public static boolean isEncryptedKey(String keyFile) throws CommandException {
boolean res = false;
try {
String f = FileUtils.readSmallFile(keyFile);
if (f.startsWith("-----BEGIN ") && f.contains("ENCRYPTED")
&& f.endsWith(" PRIVATE KEY-----" + NL)) {
res=true;
}
}
catch (IOException ioe) {
throw new CommandException(Strings.get("error.parsing.key", keyFile, ioe.getMessage()));
}
return res;
}
代码示例来源:origin: org.glassfish.main.cluster/cluster-cli
private int kill() throws CommandException {
File prevPid = null;
String pids = null;
try {
prevPid = new File(getServerDirs().getPidFile().getPath() + ".prev");
if (!prevPid.canRead())
throw new CommandException(Strings.get("StopInstance.nopidprev", prevPid));
pids = FileUtils.readSmallFile(prevPid).trim();
String s = ProcessUtils.kill(Integer.parseInt(pids));
if (s != null && logger.isLoggable(Level.FINER))
logger.finer(s);
}
catch (CommandException ce) {
throw ce;
}
catch (Exception ex) {
throw new CommandException(Strings.get("StopInstance.pidprevreaderror",
prevPid, ex.getMessage()));
}
return 0;
}
}
代码示例来源:origin: org.glassfish.main.admin/server-mgmt
private int kill() throws CommandException {
File prevPid = null;
String pids = null;
try {
prevPid = new File(getServerDirs().getPidFile().getPath() + ".prev");
if (!prevPid.canRead())
throw new CommandException(Strings.get("StopDomain.nopidprev", prevPid));
pids = FileUtils.readSmallFile(prevPid).trim();
String s = ProcessUtils.kill(Integer.parseInt(pids));
if(s != null)
logger.finer(s);
}
catch (CommandException ce) {
throw ce;
}
catch (Exception ex) {
throw new CommandException(Strings.get("StopDomain.pidprevreaderror",
prevPid, ex.getMessage()));
}
return 0;
}
}
代码示例来源:origin: org.glassfish.admin/admin-cli
private int kill() throws CommandException {
File prevPid = null;
String pids = null;
try {
prevPid = new File(getServerDirs().getPidFile().getPath() + ".prev");
if (!prevPid.canRead())
throw new CommandException(Strings.get("StopDomain.nopidprev", prevPid));
pids = FileUtils.readSmallFile(prevPid).trim();
String s = ProcessUtils.kill(Integer.parseInt(pids));
if(s != null)
logger.finer(s);
}
catch (CommandException ce) {
throw ce;
}
catch (Exception ex) {
throw new CommandException(Strings.get("StopDomain.pidprevreaderror",
prevPid, ex.getMessage()));
}
return 0;
}
}
代码示例来源:origin: org.glassfish.main.cluster/cluster-ssh
String key = null;
try {
key = FileUtils.readSmallFile(file);
代码示例来源:origin: org.glassfish.main.admin/server-mgmt
private void install() throws ProcessManagerException {
// it IS an error to not be able to install
if (info.dryRun) {
try {
// dry-run not so useful on Windows. Very useful on UNIX...
xmlFileCopy = Strings.get("xmlfiledump") + FileUtils.readSmallFile(targetXml);
}
catch (IOException ex) {
// oh well....
}
if (!targetWin32Exe.delete())
dryRun("Dry Run error: delete failed for targetWin32Exe " + targetWin32Exe);
if (!targetXml.delete())
dryRun("Dry Run error: delete failed for targetXml " + targetXml);
}
else {
ProcessManager mgr = new ProcessManager(targetWin32Exe.getPath(), "install");
mgr.setEcho(false);
mgr.execute();
int ret = mgr.getExitValue();
if (ret != 0)
throw new RuntimeException(Strings.get("windows.services.install.bad",
"" + ret, mgr.getStdout(), mgr.getStderr()));
trace("Install STDERR: " + mgr.getStderr());
trace("Install STDOUT: " + mgr.getStdout());
}
}
内容来源于网络,如有侵权,请联系作者删除!