Microsoft
Software
Hardware
Network
Question : How do I use a user input filename and then read line by line
I am really new to Java and am feeling quite challenged at the moment! :)
I need to allow the user to input the filename to read from, so I'm using a scanner:
try{
Scanner in = new Scanner(System.in);
System.out.print("Enter name of input file: ");
Scanner input=new Scanner(new FileReader(in.nextLine()))
;
if(!input.hasNext())
{System.out.println("File Empty - aborting");
System.exit(0);}
while (input.hasNextLine())
{
After reading the input file, I need to count the characters and output the number of chars per line into a text file (so the number of lines in the source file will match the output file). I think I need to use BufferedInputStream to read it line by line, but I'm not sure how to use it with the scanner, or if what I have above is good enough. All the examples I have found used a static file name with BufferedInputStream.
Thanks!!!
Answer : How do I use a user input filename and then read line by line
no need for a scanner, see the following for how to read the file
http://helpdesk.objects.co
m.au/java/
how-do-i-r
ead-a-text
-
file-line
-by-line
Random Solutions
NT Backup error: DO_NOT_REMOVE_NtFrs_PreIns<wbr />tall_Direc<wbr />tory" - skipped.
How get or create signed certificate CA in redhat enterprise linux
Cisco 2811 router definig url filetering server
how to set up a http or ftp server using windows xp pro
Wireless Connection Drops in Windows XP - Event IDs 8033 & 4202
How can I detect WebLogic Admin server by it's command line?
wilcard dns and complex htaccess
BT wireless internet via Apple Airport to XP: one works; one doesn't
Mail doesnt get delived to my server from hotmail
Inexpensive GPS