Returns a base64 encoded string representation of the contents of the
resource associated with the {@link URLConnection}.

@param in
The input stream for the resource
@return The base64 encoded string representation of the resource
@throws IOException
197617
protected String getBase64(InputStream in) throws IOException {
		ByteArrayOutputStream out = new ByteArrayOutputStream();
		CopyUtil.copy(in, out);
		return new String(Base64.encodeBase64(out.toByteArray()), "UTF-8"); //$NON-NLS-1$
	}
690853
private static String getString(InputStream in) {
        try {
            StringBuffer out = new StringBuffer();
            BufferedReader reader =
                    new BufferedReader(new InputStreamReader(in));
            String line = reader.readLine();
            while (line != null) {
                out.append(line + "\n");
                line = reader.readLine();
            }
            return out.toString();
        } catch (Exception e) {
            return "[Error reading response body: " + e.getClass().getName()
                    + ": " + e.getMessage() + "]";
        }
    }
67248
public String asBase64() throws IOException {
        return asBase64(BaseEncoding.Dialect.STANDARD, BaseEncoding.Padding.STANDARD);
    }
1074091
static String readString(final DataInput in) throws IOException {
		final byte[] bytes = new byte[readInt(in)];
		in.readFully(bytes);
		return new String(bytes, "UTF-8");
	}
1238402
def base64_encodestring(instr):
    '''
    
    '''
    return salt.utils.stringutils.to_unicode(
        base64.encodestring(salt.utils.stringutils.to_bytes(instr)),
        encoding='utf8' if salt.utils.platform.is_windows() else None
    )
541773
public static String encode(final String source) {
		if (source == null) {
			return null;
		}
		return encodeInToBase64(source.getBytes());
	}
909841
protected byte[] encodeString(String in) {
    byte[] rv = null;
    try {
      rv = in.getBytes(this.charset);
    } catch (UnsupportedEncodingException e) {
      throw new RuntimeException(e);
    }
    return rv;
  }
911042
public static StreamCutInternal from(String base64String) {
        Exceptions.checkNotNullOrEmpty(base64String, "base64String");
        String[] split = decompressFromBase64(base64String).split(":", 5);
        Preconditions.checkArgument(split.length == 5, "Invalid string representation of StreamCut");

        final Stream stream = Stream.of(split[1]);
        List<Integer> segmentNumbers = stringToList(split[2], Integer::valueOf);
        List<Integer> epochs = stringToList(split[3], Integer::valueOf);
        List<Long> offsets = stringToList(split[4], Long::valueOf);

        final Map<Segment, Long> positions = IntStream.range(0, segmentNumbers.size()).boxed()
                .collect(Collectors.toMap(i ->  new Segment(stream.getScope(), stream.getStreamName(),
                                                            StreamSegmentNameUtils.computeSegmentId(segmentNumbers.get(i), epochs.get(i))),
                                          offsets::get));
        return new StreamCutImpl(stream, positions);
    }
633924
public static String readStringFromUrlGeneric(String url)
            throws IOException {
        InputStream is = null;
        URL urlObj = null;
        String responseString = PcConstants.NA;
        try {
            urlObj = new URL(url);
            URLConnection con = urlObj.openConnection();

            con.setConnectTimeout(ParallecGlobalConfig.urlConnectionConnectTimeoutMillis);
            con.setReadTimeout(ParallecGlobalConfig.urlConnectionReadTimeoutMillis);
            is = con.getInputStream();

            BufferedReader rd = new BufferedReader(new InputStreamReader(is,
                    Charset.forName("UTF-8")));
            responseString = PcFileNetworkIoUtils.readAll(rd);

        } finally {

            if (is != null) {
                is.close();
            }

        }

        return responseString;
    }
1048517
public static String base64Encode(String plainTextString) {
        String encoded = new String(Base64.getEncoder().encode(plainTextString.getBytes()));
        return encoded;
    }
1092255
public static String asUTF8String(InputStream in) {
        // Precondition check
        Validate.notNull(in, "Stream must be specified");

        StringBuilder buffer = new StringBuilder();
        String line;

        try {
            BufferedReader reader = new BufferedReader(new InputStreamReader(in, CHARSET_UTF8));
            while ((line = reader.readLine()) != null) {
                buffer.append(line).append(Character.LINE_SEPARATOR);
            }
        } catch (IOException ioe) {
            throw new RuntimeException("Error in obtaining string from " + in, ioe);
        } finally {
            try {
                in.close();
            } catch (IOException ignore) {
                if (log.isLoggable(Level.FINER)) {
                    log.finer("Could not close stream due to: " + ignore.getMessage() + "; ignoring");
                }
            }
        }

        return buffer.toString();
    }
1245290
private String readLine(InputStream in) throws IOException {
	StringBuffer buf = new StringBuffer();
	int c, length = 0;

	while(true) {
	    c = in.read();
	    if (c == -1 || c == '\n' || length > 512) {
		break;
	    } else if (c == '\r') {
		in.read();
		return buf.toString();
	    } else {
		buf.append((char)c);
		length++;
	    }

	}
	return buf.toString();
    }
72111
public static String inputStreamToString(InputStream in) {
    final int BUFFER_SIZE = 1024;
    BufferedReader bufferedReader;
    try {
      bufferedReader = new BufferedReader(new InputStreamReader(in, "UTF-8"));
    } catch (UnsupportedEncodingException e) {
      throw new DatasetException(
          "Platform doesn't support UTF-8. It must!", e);
    }
    char[] buffer = new char[BUFFER_SIZE];
    StringBuilder stringBuilder = new StringBuilder(BUFFER_SIZE);
    int bytesRead = 0;
    try {
      while ((bytesRead = bufferedReader.read(buffer, 0, BUFFER_SIZE)) > 0) {
        stringBuilder.append(buffer, 0, bytesRead);
      }
    } catch (IOException e) {
      throw new DatasetException("Error reading from input stream", e);
    }
    return stringBuilder.toString();
  }
385428
public static String readURLToString(URL u, String encoding) throws IOException {
		for (int i = 0; i < 30; ++i) {
			URLConnection conn = u.openConnection();

			// handle HTTP URLs
			if (conn instanceof HttpURLConnection) {
				HttpURLConnection hconn = (HttpURLConnection)conn;

				// set timeouts
				hconn.setConnectTimeout(15000);
				hconn.setReadTimeout(15000);

				// handle redirects
				switch (hconn.getResponseCode()) {
				case HttpURLConnection.HTTP_MOVED_PERM:
				case HttpURLConnection.HTTP_MOVED_TEMP:
					String location = hconn.getHeaderField("Location");
					u = new URL(u, location);
					continue;
				}
			}

			return readStreamToString(conn.getInputStream(), encoding);
		}

		throw new IOException("Too many HTTP redirects");
	}
1209241
public static InputStream getContentStream(String stringUrl) throws MalformedURLException, IOException {
        URL url = new URL(stringUrl);
        
        URLConnection urlConnection = url.openConnection();
        
        InputStream is = urlConnection.getInputStream();
        if ("gzip".equals(urlConnection.getContentEncoding())) {
           is = new GZIPInputStream(is);
        }

        return is;
    }
724970
public static CharSequence encode(CharSequence in) throws IOException{
		if(in == null) return null;
		// Assume that some but not all characters need to be escaped.
		StringBuilder sb = new StringBuilder(in.length() * 2);
		encode(in, sb);
		return sb;
	}
840981
public static JWEHeader fromBase64String(String base64) throws IOException {
        String json = MessageSecurityHelper.base64UrltoString(base64);
        return deserialize(json);
    }