I’m stuck on Stage #qv8.
I’ve tried checking the file content. The last couple of lines check the contents of the file being written and I’m getting the correct content back. Not sure what the error is about though.
Here are my logs:
remote: [your_program] /tmp/data/codecrafters.io/http-server-tester/pear_orange_raspberry_pear
remote: [tester::#QV8] Failed to read response:
remote: [tester::#QV8] Received: "" (no content received)
remote: [tester::#QV8] ^ error
remote: [tester::#QV8] Error: Expected: HTTP-version, Received: ""
remote: [tester::#QV8] Test failed
remote: [tester::#QV8] Terminating program
remote: [your_program] checking
remote: [your_program] grape strawberry banana apple raspberry pineapple strawberry banana
remote: [tester::#QV8] Program terminated successfully
remote:
And here’s a snippet of my code:
try {
in.readLine();
in.readLine();
String[] path = lines[1].split("/");
String fileName = path[2];
String content = in.readLine();
String filePath = commandLine.getArgList().get(0) + fileName;
System.out.println(filePath);
FileReaderUtil fileReaderUtil = new FileReaderUtil(filePath);
fileReaderUtil.writeStringToFileAndCreateDirectory(content);
System.out.println("checking");
FileReaderUtil fileReaderUtilCheck = new FileReaderUtil(filePath);
String fileContent = fileReaderUtilCheck.readFileAsString();
System.out.println(fileContent);
this.clientSocket.getOutputStream().write(response.get("fileCreated").getBytes());
}catch (IOException e){
this.clientSocket.getOutputStream().write(response.get("notFound").getBytes());
e.printStackTrace();
}