Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Java reading files NEED HELP. I don't know how to answer this question I am using the right syntax discussed in class and its giving
Java reading files NEED HELP. I don't know how to answer this question I am using the right syntax discussed in class and its giving me an error. Please help me fix the code so it work I don't want a different variation of code i want to use the syntatically that i was trying to do just need correction PLEASE.
1 import java.io.IOException; VariablesChallengePS/src/VariablesChallengePS java 2 import java .nio.file. le 3 import java.nio.file. Paths; 5 public class FilesLecture1 5 points static string Q1 (String filename) 10 TODO: Read the input file and return its contents as a single string containing all lines of the file 11 Concatenated together 12 try filename src/test.txt 14 for (string line Files .readALLLines hs.get (filename System.out.println(line); 17 catch (IOException ex 18 ex.printstackTrace 19 20 return "line 23 25 public static void main(String[] args) f String result 01 src/test File. txt") 26 System.out.println( result 27 28 Javadoc Q. Declaration Console erminated> FilesLecture1 ava Application] CAProgram Files NavaVre1.8.0 121 binyavaw.exe (Feb 27, 2017, 9:22:25 AM ava.nio.file.NoSuchFileException src\test.txt at ion (Unknown Source at ion (Unknown Source at ion (Unknown Source at sun.nio.fs. Windows FilesystemProvider.newBytechannel (Unknown Source) at java .nio. file. Files.newBytechannel (Unknown Source) at java nio.file, Files.newBytechannel(Unknown Source) at java .nio.file.spi. FilesystemProvider.newInputstream(Unknown Source) at java. nio.file. Files.newInputstream(Unknown Source) at iava nio.file. Files newBufferedReader (Unknown Source) Writable Smart Insert 24:4
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started