20 điểm
Hãy tìm lỗi trong đoạn mã sau :
import java.io.ByteArrayOutputStream;
class Main {
public static void main(String[] args) {
String data = "This is a line of text inside the string.";
try {
// Creates an output stream
ByteArrayOutputStream out = new ByteArrayOutputStream();
byte[] array = data.getBytes();
// Writes data to the output stream
out.write(array);
// Retrieves data from the output stream in string format
String streamData = out.toString();
System.out.println("Output stream: " + streamData);
out;close();
}
catch(Exception e) {
e.getStackTrace();
}
}
}
Quảng cáo
1 câu trả lời 345
Hãy tìm lỗi trong đoạn mã sau :
import java.io.ByteArrayOutputStream;
class Main {
public static void main(String[] args) {
String data = "This is a line of text inside the string.";
try {
// Creates an Outputstream
ByteArrayOutputStream out = new ByteArrayOutputStream();
byte[] array = data.getBytes();
// Writes data to the output stream
out.write(array);
// Retrieves data from the output stream in string format
String streamData = out.toString();
System.out.println("Output stream: " + streamData);
out;close();
}
catch(Exception e) {
e.getStackTrace();
}
}
}
Quảng cáo
Bạn cần hỏi gì?
Câu hỏi hot cùng chủ đề
-
Đã trả lời bởi chuyên gia
61633 -
Đã trả lời bởi chuyên gia
33063 -
Hỏi từ APP VIETJACK
Đã trả lời bởi chuyên gia
25274 -
Đã trả lời bởi chuyên gia
23844
