Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialThe Hacker
20,260 PointsI believe it's ok, but it says: Compilation Error. Any ideas?
//Problem: Finally, set the 'responseData' String variable with the data in 'charArray'. Convert it using the String constructor that takes a char array as its parameter.
// Code to read InputStream goes here!
InputStream inputStream = connection.getInputStream();
Reader reader = new InputStreamReader(inputStream);
char[] charArray = new char[connection.getContentLength()];
reader.read(charArray);
String responseData = new String(charArray);
3 Answers
Jason Thorn
2,611 PointsHi Pedro
I think the responseData variable is already declared at the very top of the example, so you just need: responseData = new String(charArray);
The Hacker
20,260 PointsThanks Jason,
You are absolutely right I didn't noticed that the variable was already declared.
Jason Thorn
2,611 PointsI'm always doing that :) I think its the color scheme!