當前位置: 首頁>>代碼示例>>Java>>正文


Java StringReader.read方法代碼示例

本文整理匯總了Java中java.io.StringReader.read方法的典型用法代碼示例。如果您正苦於以下問題:Java StringReader.read方法的具體用法?Java StringReader.read怎麽用?Java StringReader.read使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.io.StringReader的用法示例。


在下文中一共展示了StringReader.read方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: changeLess32toXML

import java.io.StringReader; //導入方法依賴的package包/類
/**
 * Method changeLess32toXML
 *
 * @param string
 * @return normalized string
 * @throws IOException
 */
static String changeLess32toXML(String string) throws IOException {
    StringBuilder sb = new StringBuilder();
    StringReader sr = new StringReader(string);
    int i = 0;

    while ((i = sr.read()) > -1) {
        if (i < 32) {
            sb.append('\\');
            sb.append(Integer.toHexString(i));
        } else {
            sb.append((char) i);
        }
    }

    return sb.toString();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:24,代碼來源:RFC2253Parser.java

示例2: nextNibble

import java.io.StringReader; //導入方法依賴的package包/類
private static int nextNibble(StringReader r) throws IOException {
    while (true) {
        int ch = r.read();
        if (ch == -1) {
            return -1;
        } else if ((ch >= '0') && (ch <= '9')) {
            return ch - '0';
        } else if ((ch >= 'a') && (ch <= 'f')) {
            return ch - 'a' + 10;
        } else if ((ch >= 'A') && (ch <= 'F')) {
            return ch - 'A' + 10;
        } else if (ch == 'X') {
            return -2;
        }
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:17,代碼來源:TestTransmit.java

示例3: skipLws

import java.io.StringReader; //導入方法依賴的package包/類
private static int skipLws(StringReader input, boolean withReset)
        throws IOException {

    if (withReset) {
        input.mark(1);
    }
    int c = input.read();

    while (c == 32 || c == 9 || c == 10 || c == 13) {
        if (withReset) {
            input.mark(1);
        }
        c = input.read();
    }

    if (withReset) {
        input.reset();
    }
    return c;
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:21,代碼來源:HttpParser.java

示例4: skipConstant

import java.io.StringReader; //導入方法依賴的package包/類
private static SkipConstantResult skipConstant(StringReader input,
        String constant) throws IOException {
    int len = constant.length();

    int c = skipLws(input, false);

    for (int i = 0; i < len; i++) {
        if (i == 0 && c == -1) {
            return SkipConstantResult.EOF;
        }
        if (c != constant.charAt(i)) {
            input.skip(-(i + 1));
            return SkipConstantResult.NOT_FOUND;
        }
        if (i != (len - 1)) {
            c = input.read();
        }
    }
    return SkipConstantResult.FOUND;
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:21,代碼來源:HttpParser.java

示例5: readToken

import java.io.StringReader; //導入方法依賴的package包/類
/**
 * @return the token if one was found, the empty string if no data was
 *         available to read or <code>null</code> if data other than a token
 *         was found
 */
private static String readToken(StringReader input) throws IOException {
	StringBuilder result = new StringBuilder();

	int c = skipLws(input, false);

	while (c != -1 && isToken(c)) {
		result.append((char) c);
		c = input.read();
	}
	// Skip back so non-token character is available for next read
	input.skip(-1);

	if (c != -1 && result.length() == 0) {
		return null;
	} else {
		return result.toString();
	}
}
 
開發者ID:how2j,項目名稱:lazycat,代碼行數:24,代碼來源:HttpParser.java

示例6: skipLws

import java.io.StringReader; //導入方法依賴的package包/類
private static int skipLws(StringReader input, boolean withReset) throws IOException {

		if (withReset) {
			input.mark(1);
		}
		int c = input.read();

		while (c == 32 || c == 9 || c == 10 || c == 13) {
			if (withReset) {
				input.mark(1);
			}
			c = input.read();
		}

		if (withReset) {
			input.reset();
		}
		return c;
	}
 
開發者ID:how2j,項目名稱:lazycat,代碼行數:20,代碼來源:HttpParser.java

示例7: changeWStoXML

import java.io.StringReader; //導入方法依賴的package包/類
/**
 * Method changeWStoXML
 *
 * @param string
 * @return normalized string
 * @throws IOException
 */
static String changeWStoXML(String string) throws IOException {
    StringBuilder sb = new StringBuilder();
    StringReader sr = new StringReader(string);
    int i = 0;
    char c;

    while ((i = sr.read()) > -1) {
        c = (char) i;

        if (c == '\\') {
            char c1 = (char) sr.read();

            if (c1 == ' ') {
                sb.append('\\');

                String s = "20";

                sb.append(s);
            } else {
                sb.append('\\');
                sb.append(c1);
            }
        } else {
            sb.append(c);
        }
    }

    return sb.toString();
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:37,代碼來源:RFC2253Parser.java

示例8: splitFormulas

import java.io.StringReader; //導入方法依賴的package包/類
/**
 * @param A string containing a comma separated list of formulas
 * @return an array with the input formulas split up
 * @throws IOException
 */
public String[] splitFormulas(String str) throws IOException {
    StringReader strR = new StringReader(str);
    ArrayList<String> formulaList = new ArrayList<String>();

    int next;
    StringBuilder strB = new StringBuilder();
    int unmatchedLeftPar = 0;
    while ((next = strR.read()) != -1) {
        char ch = (char) next;

        switch (ch) {
            case ',':
                if (unmatchedLeftPar == 0) {
                    formulaList.add(strB + "");
                    strB = new StringBuilder();
                    continue;
                }
                break;

            case '(':
                unmatchedLeftPar++;
                break;

            case ')':
                unmatchedLeftPar = (unmatchedLeftPar == 0) ? 0 : --unmatchedLeftPar;
                break;

            default:
                break;
        }
        if(ch != ' '){
        	strB.append(ch);
        }

    }
    formulaList.add(strB + "");
    return formulaList.toArray(new String[formulaList.size()]);
}
 
開發者ID:nonilole,項目名稱:Conan,代碼行數:44,代碼來源:HelpView.java

示例9: normalizeV

import java.io.StringReader; //導入方法依賴的package包/類
/**
 * Method normalizeV
 *
 * @param str
 * @param toXml
 * @return normalized string
 * @throws IOException
 */
static String normalizeV(String str, boolean toXml) throws IOException {
    String value = trim(str);

    if (value.startsWith("\"")) {
        StringBuilder sb = new StringBuilder();
        StringReader sr = new StringReader(value.substring(1, value.length() - 1));
        int i = 0;
        char c;

        while ((i = sr.read()) > -1) {
            c = (char) i;

            //the following char is defined at 4.Relationship with RFC1779 and LDAPv2 inrfc2253
            if ((c == ',') || (c == '=') || (c == '+') || (c == '<')
                || (c == '>') || (c == '#') || (c == ';')) {
                sb.append('\\');
            }

            sb.append(c);
        }

        value = trim(sb.toString());
    }

    if (toXml) {
        if (value.startsWith("#")) {
            value = '\\' + value;
        }
    } else {
        if (value.startsWith("\\#")) {
            value = value.substring(1);
        }
    }

    return value;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:45,代碼來源:RFC2253Parser.java

示例10: decode

import java.io.StringReader; //導入方法依賴的package包/類
public static String decode(StringReader reader, int key) throws IOException {
    int a;
    StringBuffer res = new StringBuffer();

    try {
        while ((a = reader.read()) != -1) {
            res.append(Character.toString((char) (a + key)));
        }
    } catch (Exception e) {
        return new String();
    }

    return res.toString();
}
 
開發者ID:avedensky,項目名稱:JavaRushTasks,代碼行數:15,代碼來源:Solution.java

示例11: main

import java.io.StringReader; //導入方法依賴的package包/類
public static void main(String[] args)
throws IOException{
    StringReader in=new StringReader(
            BufferedInputFile.read("./src/main/java/io/source/hello.txt"));
    int c;
    while ((c=in.read())!=-1){
        System.out.print((char)c);
    }
}
 
開發者ID:sean417,項目名稱:LearningOfThinkInJava,代碼行數:10,代碼來源:MemoryInput.java

示例12: init

import java.io.StringReader; //導入方法依賴的package包/類
public void init() throws IOException {
  final StringReader reader = new StringReader(this.relationData);

  int open = 0;
  int offset = 1;
  int c = reader.read();
  while (c != -1) {
    if (c == '[' || c == '{') {
      open++;
    } else if (c == ']' || c == '}') {
      open--;
    }

    if (open == 1 && c == ',') {
      reader.close();
      break;
    }

    offset++;
    c = reader.read();
  }
  reader.close();

  if (offset > this.relationData.length()) {
    this.lowerBoundData =
        this.relationData.substring(this.relationData.indexOf("[") + 1, offset - 2);
    this.upperBoundData = this.relationData.substring(offset - 2, this.relationData.length() - 1);
  } else {
    this.lowerBoundData =
        this.relationData.substring(this.relationData.indexOf("[") + 1, offset - 1);
    this.upperBoundData = this.relationData.substring(offset, this.relationData.length() - 1);
  }

  this.parse2Tuples();
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:36,代碼來源:RelationParser.java

示例13: readQuotedString

import java.io.StringReader; //導入方法依賴的package包/類
/**
 * @return the quoted string if one was found, null if data other than a
 *         quoted string was found or null if the end of data was reached
 *         before the quoted string was terminated
 */
private static String readQuotedString(StringReader input,
        boolean returnQuoted) throws IOException {

    int c = skipLws(input, false);

    if (c != '"') {
        return null;
    }

    StringBuilder result = new StringBuilder();
    if (returnQuoted) {
        result.append('\"');
    }
    c = input.read();

    while (c != '"') {
        if (c == -1) {
            return null;
        } else if (c == '\\') {
            c = input.read();
            if (returnQuoted) {
                result.append('\\');
            }
            result.append(c);
        } else {
            result.append((char) c);
        }
        c = input.read();
    }
    if (returnQuoted) {
        result.append('\"');
    }

    return result.toString();
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:41,代碼來源:HttpParser.java

示例14: readQuotedToken

import java.io.StringReader; //導入方法依賴的package包/類
/**
 * Token can be read unambiguously with or without surrounding quotes so
 * this parsing method for token permits optional surrounding double quotes.
 * This is not defined in any RFC. It is a special case to handle data from
 * buggy clients (known buggy clients for DIGEST auth include Microsoft IE 8
 * &amp; 9, Apple Safari for OSX and iOS) that add quotes to values that
 * should be tokens.
 *
 * @return the token if one was found, null if data other than a token or
 *         quoted token was found or null if the end of data was reached
 *         before a quoted token was terminated
 */
private static String readQuotedToken(StringReader input)
        throws IOException {

    StringBuilder result = new StringBuilder();
    boolean quoted = false;

    int c = skipLws(input, false);

    if (c == '"') {
        quoted = true;
    } else if (c == -1 || !isToken(c)) {
        return null;
    } else {
        result.append((char) c);
    }
    c = input.read();

    while (c != -1 && isToken(c)) {
        result.append((char) c);
        c = input.read();
    }

    if (quoted) {
        if (c != '"') {
            return null;
        }
    } else {
        // Skip back so non-token character is available for next read
        input.skip(-1);
    }

    if (c != -1 && result.length() == 0) {
        return null;
    } else {
        return result.toString();
    }
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:50,代碼來源:HttpParser.java

示例15: execute

import java.io.StringReader; //導入方法依賴的package包/類
@Override
public boolean execute(String[] tokens, String line) throws Exception {
    if (tokens.length < 3) {
        err.println("Usage: " + syntaxString());
        return false;

    }
    if (!checkStoreSettings()) return false;

    StringReader sr = new StringReader(line);
    while (sr.read() != ' ');
    JsonParser jp = mjf.createJsonParser(sr);
    
    JsonNode keyNode = validateJson(jp);
    if (keyNode == null) return false;
    JsonNode valueNode = validateJson(jp);
    if (valueNode == null) return false;

    ObjectWriter writer = mapper.writerWithDefaultPrettyPrinter();
    out.println("Putting Key:");
    out.println(writer.writeValueAsString(keyNode));
    out.println("\nValue:");
    out.println(writer.writeValueAsString(valueNode));
    out.flush();

    storeClient.put(keyNode, valueNode);
    out.println("Success");
                
    return false;
}
 
開發者ID:nsg-ethz,項目名稱:iTAP-controller,代碼行數:31,代碼來源:SyncClient.java


注:本文中的java.io.StringReader.read方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。