java.io.Reader#toString ( )源码实例Demo

下面列出了java.io.Reader#toString ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: cacheonix-core   文件: DOMConfigurator.java
/**
   Configure log4j by reading in a log4j.dtd compliant XML
   configuration file.

*/
public
void doConfigure(final Reader reader, LoggerRepository repository) 
                                        throws FactoryConfigurationError {
    ParseAction action = new ParseAction() {
        public Document parse(final DocumentBuilder parser) throws SAXException, IOException {
            InputSource inputSource = new InputSource(reader);
            inputSource.setSystemId("dummy://log4j.dtd");
            return parser.parse(inputSource);
        }
        public String toString() { 
            return "reader [" + reader.toString() + "]"; 
        }
    };
  doConfigure(action, repository);
}
 
源代码2 项目: netbeans   文件: ScriptingTest.java
@Override
public Object eval(Reader reader, ScriptContext context) throws ScriptException {
    throw new ScriptException(reader.toString());
}
 
源代码3 项目: netbeans   文件: ScriptingTest.java
@Override
public Object eval(Reader reader) throws ScriptException {
    throw new ScriptException(reader.toString());
}
 
源代码4 项目: netbeans   文件: ScriptingTest.java
@Override
public Object eval(Reader reader, Bindings n) throws ScriptException {
    throw new ScriptException(reader.toString());
}
 
源代码5 项目: reflectutils   文件: TranscoderUtils.java
/**
 * This will ensure that no objects that are known to be impossible to serialize properly will
 * cause problems with the transcoders by allowing them to go into loops
 * 
 * @param object
 * @return a null if the current object is not special, an empty string to indicate the 
 * object should be skipped over with no output, and any string value to indicate the
 * return value to use instead of attempting to encode the object
 */
public static String checkObjectSpecial(Object object) {
    String special = null;
    if (object != null) {
        Class<?> type = object.getClass();
        if (Class.class.isAssignableFrom(type)) {
            // class objects are serialized as the full name
            special = ((Class<?>)object).getName();
        } else if (Type.class.isAssignableFrom(type)) {
            // type just does to string
            special = ((Type)object).toString();
        } else if (Package.class.isAssignableFrom(type)) {
            // package uses name only
            special = ((Package)object).getName();
        } else if (ClassLoader.class.isAssignableFrom(type)) {
            // classloaders are skipped over entirely
            special = "";
        } else if (InputStream.class.isAssignableFrom(type)) {
            // skip IS
            special = "";
        } else if (OutputStream.class.isAssignableFrom(type)) {
            // skip OS
            special = "";
        } else if (InputStream.class.isAssignableFrom(type)) {
            // skip IS
            special = "";
        } else if (Writer.class.isAssignableFrom(type)) {
            // skip writer
            special = "";
        } else if (Reader.class.isAssignableFrom(type)) {
            // turn reader into string
            Reader reader = ((Reader)object);
            StringBuilder sb = new StringBuilder();
            try {
                while (reader.ready()) {
                    int c = reader.read();
                    if (c <= -1) {
                        break;
                    }
                    sb.append((char) c);
                }
                special = sb.toString();
            } catch (IOException e) {
                special = "Could not read from Reader ("+reader.toString()+"): " + e.getMessage();
            }
        }
    }
    return special;
}