Results 1 to 3 of 3

Thread: html and java

  1. #1
    dnbhead is offline Member
    Join Date
    Dec 2011
    Posts
    1
    Rep Power
    0

    Default html and java

    i would like to put the results of my scanner onto an html using the java program itself. i have tried using a command exec but i failed ot get it to work. any suggestions/pointers in the right direction would be excellent. heres my code so far.
    Java Code:
    import java.io.*;  
    import java.util.Scanner;
      
    public class Generator {  
      
        private File file;  
      
        public static void main(String args[]) throws FileNotFoundException {  
            Generator String = new Generator("results.txt");   		//line to input the text file
            String.processLineByLine();   					//line by line reading from the text
      
        }  
      
        public Generator(String txt) {  
            file = new File(txt);   						//open a new text file for scan after
        }  
          
        public void processLineByLine() throws FileNotFoundException {  
            Scanner scan1 = new Scanner(file);   				
            try {  //
            												//Scanner to get each line  
              while ( scan1.hasNextLine() ){  				//continue to the next line
                processLine( scan1.nextLine() );  
              }  
            }  
            finally {  
              scan1.close();  								//no next line = scanner close
            }  
          }  
      
        public void processLine(String aLine){  
                											//use a second Scanner to string the content of each line   
                Scanner scanner = new Scanner(aLine);  
                scanner.useDelimiter(",");
                while ( scanner.hasNext() ){  
                  String event = scanner.next();   // name the columns
                  String co1 = scanner.next();
                  String co2 = scanner.next();
                  String co3 = scanner.next(); 
                  String competitor1 = scanner.next(); 
                  String competitor2 = scanner.next(); 
                  String competitor3 = scanner.next();
                  
                  
    
                  System.out.println( event + ":  (Gold) " + competitor1 + co1 + ",  (Sliver) " + competitor2 + co2 + ", (Bronze) " + competitor3 + co3);  
                }  											//print out the result 
                 
                scanner.close();  							// close the scanner
              }
    Last edited by Norm; 12-13-2011 at 03:52 PM. Reason: added code tags

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,266
    Rep Power
    25

    Default Re: html and java

    put the results of my scanner onto an html
    Please explain what "onto an html" means?
    Do you want the program to write out an html file and then have a browser read that file and display it?

  3. #3
    kevinn205 is offline Member
    Join Date
    Nov 2011
    Posts
    65
    Rep Power
    0

    Default Re: html and java

    well depends if you want it to update online instatly or just have it create and load a file? I'm assuming by the code that your just trying to get it to load a file, one start would be to save the file as a html rather than a txt file, webpages tend to open as htmls, also could help if you posted what you tried :D

Similar Threads

  1. HTML/Java
    By Bomber_Will in forum New To Java
    Replies: 5
    Last Post: 03-21-2009, 09:37 PM
  2. Using HTML in java
    By hitmen in forum AWT / Swing
    Replies: 3
    Last Post: 02-26-2009, 05:58 AM
  3. Java + html
    By GabWit in forum New To Java
    Replies: 4
    Last Post: 01-25-2009, 03:58 AM
  4. How can I include a html file in html textarea?
    By surya_dks in forum New To Java
    Replies: 2
    Last Post: 10-04-2008, 07:20 AM
  5. Java Applet HTML
    By ownlol in forum Java Applets
    Replies: 4
    Last Post: 07-21-2008, 02:59 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •