public class Example {
public static void main(String[] args) {
String mystring = "This is an example";
// Must be caught or declared to be thrown
try {
InputStream stream = new ByteArrayInputStream(mystring.getBytes("UTF-8"));
} catch (Exception e) {
}
}
}
Saturday, January 25, 2014
How do I convert a String to an InputStream in Java?
Source:
Blog Archive
-
▼
2014
(92)
-
▼
January
(82)
- How to rethrow an exception in java?
- How to handle more than one type of exception?
- error: Class names, 'HelloWorld', are only accepte...
- How to initialize an array in java?
- How to throw an exception in java?
- How to propagate an exception in java?
- How to print a java stack trace from an exception?
- Example on how to catch multiple exception types
- Creating your own exception class in java
- Java Exception Handling: Basic Try Catch Finally
- The use of try and catch in java.
- Classic Tower Of Hanoi Example
- Calculate the time it takes for light to travel fr...
- How to round a number to n'th decimal places in java?
- Quadratic Formula Example in java.
- How to find prime numbers in java?
- Calculating divisors in java.
- Leibniz Formula For PI
- Java program to generate Harmonic Series
- How to generate random numbers within a range?
- Java floor and ceiling example.
- Fibonacci recursion example in java.
- Factorial recursion example in java.
- Using exponents in java
- Euclidean Algorithm in java.
- Calculating compound interest over five years.
- Java bit shifting example.
- Calculating the area of a circle.
- Java program to print Floyd's Triangle.
- Finding all Leap Years between a range of years.
- Java program to list prime numbers.
- Java program to reverse a number.
- How to list java TimeZone IDs?
- How to convert Celsius to Fahrenheit?
- How to convert Fahrenheit to Celsius?
- How to calculate total seconds in a year?
- How do I calculate someone's age in Java?
- How can I increment a date by one day in Java?
- Example using the Calendar API
- How do I display a date and time in different time...
- How to convert a string to a long?
- How to print quotes in java?
- How to use a string in switch case?
- How to convert a string to a double?
- How to generate a random String?
- How to convert a String to a Hexadecimal?
- How to remove line breaks from a file?
- How to remove the last character from a string?
- How to capitalize the first char of each word in a...
- How to remove duplicate white spaces in a string?
- How to convert Strings to and from UTF8 byte arrays?
- How to convert comma separated String to ArrayList?
- Test if a string is not null and empty
- Convert an ArrayList to a String
- How do I count the number of occurrences of a char...
- Left padding numbers with zeros
- String to Date conversion
- How to use java.String.format?
- How to convert a string to int?
- How to check if a string contains a substring?
- How to remove leading and trailing whitespace in a...
- How to determine the length of a string?
- Concatenating Strings in Java
- How to convert a string into upper case?
- Iterate over all the chars in a String
- How to determine the Unicode code of a String?
- How to replace a substring inside a string?
- How to remove a character from a string ?
- How to reverse a String?
- How to compare two strings ?
- Set Posix File Permissions
- Split a String with StringTokenizer
- How to split a String
- Sorting an ArrayList
- Selection Sort
- Quick Sort
- Insertion Sort
- Heap Sort
- Exchange Sort
- Bubble Sort
- Bucket Sort
- How do I convert a String to an InputStream in Java?
-
▼
January
(82)