Hi there,
I am currently reading in .java files and just printing their content out to the console.
My code is:
Scanner scnr = null;
try
{
scnr = new Scanner( new File( SourceCodeFiles.get(0)) );
while( scnr.hasNext() ){
String word = scnr.next();
System.out.println(word);
}
}
catch( FileNotFoundException e )
{
System.out.println( "File doesn't exist!" );
}
finally
{
if( scnr != null )
scnr.close();
}
This code prints out each word up until a space and then the next one etc etc.
I was wondering if there was a way to use the scanner to print out all the contents, maintaining their formatting structure?
If anyone has any ideas they would be much appreciated, thank you for your time,
beccy :)