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


Java StringReader.close方法代碼示例

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


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

示例1: saveImage

import java.io.StringReader; //導入方法依賴的package包/類
private void saveImage(String svgData) throws Exception{
	PNGTranscoder coder=new PNGTranscoder();
	svgData="<?xml version=\"1.0\" encoding=\"utf-8\"?>"+svgData;
	//ByteArrayInputStream fin=new ByteArrayInputStream(svgData.getBytes());
	StringReader reader=new StringReader(svgData);
	TranscoderInput input=new TranscoderInput(reader);
	String tempDir=ContextHolder.getBdfTempFileStorePath()+DIR;
	File f=new File(tempDir);
	if(!f.exists())f.mkdirs();
	FileOutputStream fout=new FileOutputStream(tempDir+"/process.png");
	TranscoderOutput output=new TranscoderOutput(fout);
	try{
		coder.transcode(input, output);			
	}finally{
		reader.close();
		//fin.close();
		fout.close();			
	}
}
 
開發者ID:bsteker,項目名稱:bdf2,代碼行數:20,代碼來源:DesignerServiceController.java

示例2: receiveResponse

import java.io.StringReader; //導入方法依賴的package包/類
protected Document receiveResponse() throws IOException, DocumentException {
    try {
        SessionImplementor session = (SessionImplementor)new _RootDAO().getSession();
        Connection connection = session.getJdbcConnectionAccess().obtainConnection();
        String response = null;
        try {
            CallableStatement call = connection.prepareCall(iResponseSql);
            call.registerOutParameter(1, java.sql.Types.CLOB);
            call.execute();
            response = call.getString(1);
            call.close();
        } finally {
        	session.getJdbcConnectionAccess().releaseConnection(connection);
        }
        if (response==null || response.length()==0) return null;
        StringReader reader = new StringReader(response);
        Document document = (new SAXReader()).read(reader);
        reader.close();
        return document;
    } catch (Exception e) {
        sLog.error("Unable to receive response: "+e.getMessage(),e);
        return null;
    } finally {
        _RootDAO.closeCurrentThreadSessions();
    }
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:27,代碼來源:BlobRoomAvailabilityService.java

示例3: parse

import java.io.StringReader; //導入方法依賴的package包/類
/**
 * parse json.
 * 
 * @param json json source.
 * @return JSONObject or JSONArray or Boolean or Long or Double or String or null
 * @throws ParseException
 */
public static Object parse(String json) throws ParseException
{
	StringReader reader = new StringReader(json);
	try{ return parse(reader); }
	catch(IOException e){ throw new ParseException(e.getMessage()); }
	finally{ reader.close(); }
}
 
開發者ID:dachengxi,項目名稱:EatDubbo,代碼行數:15,代碼來源:JSON.java

示例4: importXml

import java.io.StringReader; //導入方法依賴的package包/類
public static void importXml(String baseFileName){
    	Debug.info("filename = " + baseFileName);
   	try {
   		String fileReceiveSql =
   	        ApplicationProperties.getProperty("tmtbl.data.exchange.receive.file","{?= call timetable.receive_xml_file.receive_file(?, ?)}");
   		String exchangeDir = 
   	    	ApplicationProperties.getProperty("tmtbl.data.exchange.directory", "LOAD_SMASDEV");
           SessionImplementor session = (SessionImplementor)new _RootDAO().getSession();
           Connection connection = session.getJdbcConnectionAccess().obtainConnection();
           CallableStatement call = connection.prepareCall(fileReceiveSql);
           call.registerOutParameter(1, java.sql.Types.CLOB);
	    call.setString(2, exchangeDir);
           call.setString(3, baseFileName);
           call.execute();
           String response = call.getString(1);
           call.close();
           session.getJdbcConnectionAccess().releaseConnection(connection);
           if (response==null || response.length()==0) return;
           StringReader reader = new StringReader(response);
           Document document = (new SAXReader()).read(reader);
           reader.close();
           DataExchangeHelper.importDocument(document, null, null);           
	} catch (Exception e) {
		e.printStackTrace();
	} 
	
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:28,代碼來源:ImportXmlFromDB.java

示例5: getCookieTokens

import java.io.StringReader; //導入方法依賴的package包/類
/**
 * Tokenizes a cookie header and returns the tokens in a
 * <code>Vector</code>.
 **/
private Vector getCookieTokens(String cookieHeader) {
    StringReader sr = new StringReader(cookieHeader);
    StreamTokenizer st = new StreamTokenizer(sr);
    Vector tokens = new Vector();

    // clear syntax tables of the StreamTokenizer
    st.resetSyntax();

    // set all characters as word characters
    st.wordChars(0,Character.MAX_VALUE);

    // set up characters for quoting
    st.quoteChar( '"' ); //double quotes
    st.quoteChar( '\'' ); //single quotes

    // set up characters to separate tokens
    st.whitespaceChars(59,59); //semicolon
    st.whitespaceChars(44,44); //comma

    try {
        while (st.nextToken() != StreamTokenizer.TT_EOF) {
            tokens.addElement( st.sval.trim() );
        }
    }
    catch (IOException ioe) {
        // this will never happen with a StringReader
    }
    sr.close();
    return tokens;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:35,代碼來源:CookieJar.java

示例6: 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

示例7: parse

import java.io.StringReader; //導入方法依賴的package包/類
public static Stream<Pair<String, String>> parse(String[] args)
{
    String full = String.join(" ", args);
    StringReader reader = new StringReader(full);

    StreamTokenizer tokenizer = new StreamTokenizer(reader);
    tokenizer.resetSyntax();
    tokenizer.wordChars(0, Integer.MAX_VALUE);
    tokenizer.whitespaceChars(0, ' ');
    tokenizer.quoteChar('"');

    List<String> parsed = new ArrayList<>();
    List<String> raw = new ArrayList<>();
    int last_tt = StreamTokenizer.TT_EOF;
    int lastIndex = 0;
    try
    {
        while (tokenizer.nextToken() != StreamTokenizer.TT_EOF)
        {
            int idx = Math.min(index(reader), full.length());

            String arg = tokenizer.sval;
            String argRaw = full.substring(lastIndex, idx);

            parsed.add(arg);
            raw.add(tokenizer.ttype != '\"' ? argRaw.trim() : argRaw);

            lastIndex = idx;
            last_tt = tokenizer.ttype;
        }
    }
    catch (IOException e)
    {
        // Should never happen
        MCOpts.logger.error("Error reading string", e);
    }

    reader.close();

    if (args.length > 0 && args[args.length - 1].length() == 0)
    {
        String lastRaw = raw.size() > 0 ? Iterables.getLast(raw) : null;
        // Are we in an open quote?
        if (!(last_tt == '\"' && (lastRaw == null || lastRaw.charAt(lastRaw.length() - 1) != '\"')))
        {
            // We are currently writing a new param
            parsed.add("");
            raw.add("");
        }
    }

    return IntStream.range(0, parsed.size())
            .mapToObj(i -> Pair.of(raw.get(i), parsed.get(i)));
}
 
開發者ID:Ivorforce,項目名稱:MCOpts,代碼行數:55,代碼來源:Parameters.java

示例8: getCookieTokens

import java.io.StringReader; //導入方法依賴的package包/類
/**
 * Tokenizes a cookie header and returns the tokens in a
 * <code>Vector</code>.
 * handles the broken syntax for expires= fields ...
 * @param cookieHeader - the header to read
 * @return a Vector of cookieTokens as name=value pairs
 **/
private Vector getCookieTokens(String cookieHeader) {
    StringReader sr = new StringReader(cookieHeader);
    StreamTokenizer st = new StreamTokenizer(sr);
    Vector tokens = new Vector();

    // clear syntax tables of the StreamTokenizer
    st.resetSyntax();

    // set all characters as word characters
    st.wordChars(0,Character.MAX_VALUE);

    // set up characters for quoting
    st.quoteChar( '"' ); //double quotes
    st.quoteChar( '\'' ); //single quotes

    // set up characters to separate tokens
    st.whitespaceChars(59,59); //semicolon
    // and here we run into trouble ...
    // see http://www.mnot.net/blog/2006/10/27/cookie_fun
    // ... Notice something about the above? It uses a comma inside of the date, 
    // without quoting the value. This makes it difficult for generic processors to handle the Set-Cookie header.
    st.whitespaceChars(44,44); //comma

    try {
        while (st.nextToken() != StreamTokenizer.TT_EOF) {
        	String tokenContent=st.sval;
        	// fix expires comma delimiter token problem
        	if (tokenContent.toLowerCase().startsWith("expires=")) {
        		if (st.nextToken() != StreamTokenizer.TT_EOF) {
        			tokenContent+=","+st.sval;
        		}	// if
        	} // if        		
        	tokenContent=tokenContent.trim();
          tokens.addElement( tokenContent );
        }
    }
    catch (IOException ioe) {
        // this will never happen with a StringReader
    }
    sr.close();
    return tokens;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:50,代碼來源:CookieJar.java


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