Java实现Clob类型转String

	public String clobToString(Clob clob) throws Exception {
    
    
        String re = "";
        Reader is = null;
        BufferedReader br = null;
        try {
    
    			
        	// 得到流
        	is = clob.getCharacterStream();
        	br = new BufferedReader(is);
        	String s = br.readLine();
        	StringBuffer sb = new StringBuffer();
        	// 执行循环将字符串全部取出付值给StringBuffer由StringBuffer转成STRING
        	while (s != null) {
    
    
        		sb.append(s);
        		s = br.readLine();
        	}
        	re = sb.toString();
		} catch (Exception e) {
    
    
        	e.printStackTrace();
		}finally {
    
    
			if (is != null) {
    
    
				is.close();
			}
			if (br != null) {
    
    
				br.close();
			}
		}
        return re;
    }
String clobString = clob.getSubString(1, (int) clob.length());
String blobString = new String(blob.getBytes(1, (int) blob.length()),"GBK");

おすすめ

転載: blog.csdn.net/qq_40977118/article/details/111199903