How can I input read a line from a file and output it into the screen?

How can I input read a line from a file and output it into the screen?
If I have a file contains html code and I only want the URL, for example, www24.brinkster.com how can I read that into the buffer and write the output into the screen that using Java?
Any help will be appreciate!
======START FILE default.html ========
<html>
<body>
<br><br>
<center>
<font size=4 face=arial color=#336699>
<b>Welcome to a DerekTran's Website!</b><br>
Underconstructions.... <br>
</font> </center>
<font size=3 face=arial color=black> <br>
Hello,<br>
<br>
I've been using the PWS to run the website on NT workstation 4.0. It was working
fine. <br>
The URL should be as below: <br>
http://127.0.0.1/index.htm or http://localhost/index.htm
<p>And suddently, it stops working, it can't find the connection. I tried to figure
out what's going on, but still <font color="#FF0000">NO CLUES</font>. Does anyone
know what's going on? Please see the link for more.... I believe that I setup
everything correctly and the bugs still flying in the server.... <br>
Thank you for your help.</P>
</font>
<p><font size=3 face=arial color=black>PeerWebServer.doc
<br>
<p><font size=3 face=arial color=black>CannotFindServer.doc
<br>
<p><font size=3 face=arial color=black>HOSTS file is not found
<br>
<p><font size=3 face=arial color=black>LMHOSTS file
<br>
<p><font size=3 face=arial color=black>How to Setup PWS on NT
<BR>
<p><font size=3 face=arial color=black>Issdmin doc</BR>
Please be patient while the document is download....</font>
<font size=3 face=arial color=black><br>If you have any ideas please drop me a
few words at [email protected] </font><br>
<br>
<br>
</p>
<p><!--#include file="Hits.asp"--> </p>
</body>
</html>
========= END OF FILE ===============

Hi!
This is a possible solution to your problem.
import java.io.*;
class AddressExtractor {
     public static void main(String args[]) throws IOException{
          //retrieve the commandline parameters
          String fileName = "default.html";
          if (args.length != 0)      fileName =args[0];
           else {
               System.out.println("Usage : java AddressExtractor <htmlfile>");
               System.exit(0);
          BufferedReader in = new BufferedReader(new FileReader(new File(fileName)));
          StreamTokenizer st = new StreamTokenizer(in);
          st.lowerCaseMode(true);
          st.wordChars('/','/'); //include '/' chars as part of token
          st.wordChars(':',':'); //include ':' chars as part of token
          st.quoteChar('\"'); //set the " quote char
          int i;
          while (st.ttype != StreamTokenizer.TT_EOF) {
               i = st.nextToken();
               if (st.ttype == StreamTokenizer.TT_WORD) {          
                    if (st.sval.equals("href")) {               
                         i = st.nextToken(); //the next token (assumed) is the  '=' sign
                         i = st.nextToken(); //then after it is the href value.               
                         getURL(st.sval); //retrieve address
          in.close();
     static void getURL(String s) {     
          //Check string if it has http:// and truncate if it does
          if (s.indexOf("http://") >  -1) {
               s = s.substring(s.indexOf("http://") + 7, s.length());
          //check if not mailto: do not print otherwise
          if (s.indexOf("mailto:") != -1) return;
          //printout anything after http:// and the next '/'
          //if no '/' then print all
               if (s.indexOf('/') > -1) {
                    System.out.println(s.substring(0, s.indexOf('/')));
               } else System.out.println(s);
}Hope this helps. I used static methods instead of encapsulating everyting into a class.

Similar Messages

  • How can i erase my .me mails from my iPhone and keep them in the server

    how can i erase my .me mails from my iPhone and keep them in the server

    You can't. The iPhone doesn't actually store all your emails anyway. It is showing you what is on the server directly.
    Only the most recently accessed emails are cached (stored temporarily) on your phone for access when you are offline. If you delete an email from your iPhone, you are actually deleting it from the server.

  • Reading the data from 2 files and writing it into the 3rd file?

    Hi,
    I am reading datas from 2 files Say,
    Example1.txt Example2.txt
    Ashok ^data1^data2^data3
    Babu ^data1^data2^data3
    Chenthil ^data1^data2^data3
    Danny ^data1^data2^data3
    I want those data's to be written in a 3rd file. Say,
    Example3.txt
    Ashok^ data1^data2^data3
    Babu^ data1^data2^data3
    Chenthil^ data1^data2^data3
    Danny^ data1^data2^data3
    So that i can tokenize it with a delimeter(^) and get the values. Here how to append the datas in this form in Example3.txt. Eventhough u use FileWriter with append "true" as a parameter how they will apend like the Example3.txt file? Please do provide an answer for this..Since this is very urgent to be delivered...Expecting postive response.
    Thanx,
    JavaCrazyLover

    import java.io.*;
    import java.util.*;
    public class en
    public static void main(String args[]) throws IOException     
    {int data,data1,offset,offset1;
              FileOutputStream fos1=new FileOutputStream("c:/example3.txt");
              FileInputStream fis=new FileInputStream("c:/example1.txt");
              FileInputStream fis1=new FileInputStream("c:/example2.txt");
    while((data=fis.read())!=-1) 
         fos1.write(data);
    while((data=fis1.read())!=-1) 
    fos1.write(data);
    fis.close();
    fis1.close();
    fos1.close();
    }first create those 3 files in c:

  • How can I use a date/time from a cursor and insert it into a table later?

    I have a cursor which retrieves data from a table which includes a date column, which has date and time.
    I want to insert this value into a table which has another date column but when I do, it is dropping off the time data and putting in 00:00:00.
    I am using execute immediate and trapped the SQL I am executing:
    insert into ifsapp.GSCDB_TRANS_DTL_TAB values (
    'GSCDB_COMPANY',to_date('01-DEC-06',3,0 )
    and so you can see the date has no time.
    The plsql is:
    v_sql := 'insert into ifsapp.GSCDB_TRANS_DTL_TAB values ( '''||r_gscdbio.name||''','''||r_gscdbio.last_exec_time||''','||v_count||',0 )';
    Any help appreciated, I feel I need to use to_date and/or to_char but my head is spinning!
    Thank you

    Why are you using EXECUTE IMMEDIATE for this? And why are you not using bind variables? It'll be much easier (and more efficeint, easier to debug, etc) to just have static SQL
    INSERT INTO table_name
      VALUES( r_gscdbio.name, r_gscdbio.last_exec_time, v_count, 0 );Additionally, you'll want to explicitly specify the column list for your INSERT statement. Otherwise, if you add another column to the table, your code will break.
    Justin

  • How can I create a link to a pdf file and show it in the same webpage or in a new tab

    It is no problem to create a link. But the formats are limited and  - unbelievable -  the pdf format is not supported??!
    Where are the parameter (_blank or _self) to show it for example in the same webpage or in a new tab??!

    PDF is media.  It is not a web document.  Your end users must have plug-ins and helper apps installed on their device to see PDFs in browsers.  Depending on their settings, the PDF file may or may not launch in the browser window.  On my system, PDF files download and launch inside Acrobat Professional; not my browser.
    The safest approach is to provide a screenshot on your page with a direct link to the PDF file so people can handle it as they wish.  See example:  http://www.adobe.com/manufacturing/3dpdfsamples/3dsolutions/
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists 
    http://alt-web.com/

  • How can I copy an audio effect from a clip and paste it to another clip in the same timiline...With FCPro 7 it was all so fast........

    how can I copy an audio effect from a clip and paste it to another clip in the same timiline...With FCPro 7 it was all so fast........

    Tom Wolsky wrote:
    The advantage goes to FCP7 if you allow that it can copy and paste filters, audio and video, transformations, and other attributes separately.
    You can do that in FCPX too, as all the things you cited are listed separately in the inspector.
    Here's a little gotcha. Let's say you've color corrected a few clips and you've applied an effect to one and want to paste it the other clips. You switch off color correction and copy the clip. You select the other clips and paste effects. What do you think happens? The effect is applied, but the color correction is applied as well, only it's switched off as it was in the first clip, so all the color correction on the other clips is lost. Fun, eh?
    I'll try to replicate your gotcha - but no, that doesn't sound like fun at all!

  • How can I delete an Apple ID from one device and replace it with a different ID on that same device?

    How can I delete an Apple ID from one device and replace it with a different ID on that same device?

    Tthe brute force method: start with Settings > iCloud and turn off Find My (you will need the password), then change the iCloud ID, then go to the apps such as Messages, FaceTime, etc, and delete the Apple ID and enter the new one.

  • Hello! I was on my Mac and then I clicked on iTunes. Then I clicked on iTunes, and accidentally removed my device from my Mac, how can I get it back? Also when I plug my iPod into the computer, it downloads everything, how can I stop this. please help!thx

    Hello! I was on my Mac and then I clicked on iTunes. Then I clicked on Account, and accidentally removed my device from my Mac, how can I get it back? Also when I plug my iPod into the computer, it downloads everything that is on my computer, how can I stop this. please help! please help!!!!!!thank you

    Is the iPod still singed into the account isn Settings>iTunes and App Stores and SettingsZ>iCloudl? If it is then I would not be concerned.
    Also see:
    iTunes Store: Associating a device or computer to your Apple ID
    since you may have started the 90 day window.
    For the other "problem", go to iTunes>Preferences>Devices and check the box that says Prevent iPod....automatically syncing.

  • How can I move my iPhoto Library from one Mac to another without losing the comments on the individual photos in the process?

    How can I move my iPhoto Library from one Mac to another without losing the comments on the individual photos in the process? The source Macbook (OS 10.4.11 and iPhoto 6.0.6 (3.2.2.)) is with my husband in Germany, the target MacBook Pro (OS 10.8.5, iPhoto 11) is with me in Japan. Thanks for your help.

    I copied the iPhoto Library to a CD and from there to the new MacBook
    If you copied the library to the CD via the Finder it would be no different than the methods Terence suggested.  If you used the Share ➙ Burn menu option from inside iDVD you'll get a mini library that has to be accessed from the open library and the events/alubums copied into the destination library.  Not the same as the other methods.
    The Share ➙ Burn method is no longer supported with iPhoto 9 and later.
    OT

  • Hi, i purchased a 2 dvd digital set. i cant just download it straight to my ipad. they said i have to down load it to my i tunes, then can transfer to i pad. im not seeing how to click the files from my email, and get them into the i tunes acct... ugh.

    hi, i purchased a 2 dvd digital set. i cant just download it straight to my ipad. they said i have to down load it to my i tunes, then can transfer to i pad. im not seeing how to click the files from my email, and get them into the i tunes acct... ugh.
    i do not have a mac home pc. just a regular pc

    I had the same problem after I gave my old iPad to my parents and tried to install Netflix. This is what you have to do:  Open iTunes on your computer, the one you sync your iPad to. Then go to iTunes Store and search for and download Netflix app. After you download it, if your iPad is set to download new purchases it may start downloading on your iPad. If so, tap and hold to delete the app (because it is trying to install the new version on the iPad) Next step, go to the App Store on your iPad and find Netflix and it should say install since you already purchased it on the computer. Tap to install, and it will say the version is not compatible, tap to download a previous version. Click that and it will install the older version!    One more thing, if and when you sync to your computer again it will say something like " Unable to install Netflix on your iPad" Just click the box to never remind you again, because it's trying to sync the newer Netflix app to your iPad, but it doesn't work so it displays the message. The old app will remain on the ipad. Hope this helps, good luck

  • I filmed several takes of the same scene for a movie. I trimmed the best clips from each take and put them into the project screen. However, I can't figure out how to make it flow seamlessly as one scene. Can someone please help me??

    I filmed several takes of the same scene for a movie. I trimmed the best clips from each take and put them into the project screen. However, I can't figure out how to make it flow seamlessly as one scene. Can someone please help me??

    1-800-676-2775  apple support   tech support 1 800 275 2273
    If your computer is on one minute before it freezes, than you have one minute to secure your serial number.
    click the apple----->click about this Mac ------> click on version----> until you see the serial number.  You may have to do this a couple of times if it freezes before you have all the numbers.  A camera might help.
    Good Luck

  • How can you insert "Page Break" in a pdf file so you will specify the pages

    How can you insert "Page Break" in a pdf file so you will specify the pages

    How / from what was the PDF originally created?  It would be easiest to insert page breaks into the original document, then recreate the PDF.

  • How to Load the data from excel file(Extension is .CSV) into the temp.table

    Hi
    How to Load the data from excel file(Extension is .CSV) into the temporary table of oracle in Forms11g.
    My Forms Version is - Forms [64 Bit] Version 11.1.2.0.0 (Production)
    Kindly Suggest the Solution.
    Regards,
    Sachin

    Hello Sachin,
    You can use the following metalink note:How to Read Data from an EXCEL Spreadsheet into a Form Using Webutil Client_OLE2 (Doc ID 813535.1) and modify it a little bit.
    Instead of copy values into forms you can save them in your temporary table.
    Kind regards,
    Alex
    If someone's helpful or correct please mark it accordingly.

  • How can I copy part of a larger PDF file and create a smaller one?

    How can I copy part of a larger PDF file and create a smaller one?

    Hi,
    Copy the content of PDF file in Adobe Reader and paset it to MS Word then create PDF file from the Word file.
    This may not work for all PDF files as some PDF files are not created correctly or some content cannot be copied.
    Acrobat XI Pro has features to extract/delete/crop pages in PDF files and you can download it from www.adobe.com(Trial version- 30 days free). Or you can upgrade your subscription to Acrobat Plus and see more information at https://www.acrobat.com/acrobatplus/en/home.html
    Hisami

  • I have an Retina display MacBook Pro with HMDI out port. I also have an HDMI to Component cable with Audio Plugs. How can I get HDMI out to work with this cable when plugged into the Component and Audio ports on my TV?

    I have an Retina display MacBook Pro with HMDI out port. I also have an HDMI to Component cable with Audio Plugs. How can I get HDMI out to work with this cable when plugged into the MacBook Pro and connected to the TVs Component and Audio in ports.

    Will not work.  To my knowledge, dual converting like that isn't supported.  The Mac must detect the connected video output device and that sort of info cannot be done across an analog component uni-directional connection.

Maybe you are looking for

  • Using (Select All) for report parameter

    Hi there, I am Looking for assistance in making the the (Select All) option work for a particular report. The parameter is for product families (which there are about 47 unique results for). The report is also influenced by two other parameters, one

  • How to track changes to Financial Reports

    I am being asked by our auditors to propose a process where we monitor and document changes to our Hyperion Financial Reports used for P&Ls, Balance Sheets, etc. Is there a history kept anywhere of the modified date for reports? I know that the clien

  • Oracle 9iR2 in RHLE3 AS... I need some files...

    Hi!!! I need a patches to Install Oracle 9i(9.2.0.1) in RHEL3. I know that they are in metalink, but I don't login to metalink site... *^^* I need some patche files... opatch.zip p1866899_8171_linux.zip p2974664_11i_GENERIC.zip p3006854_9204_LINUX.zi

  • Backround audio too loud for the Smithsonian Channel

    I'm not sure if this is something Comcast has a hand in, but for the Smithsonian Channel, the background music is louder than the main audio. Watching Aerial America is nearly impossible since you can hardly hear what the guy was saying.

  • 20 to 30 hrs of battery (supposedly)

    hi everyone, about a month ago i did the battery update 1.2 and then my battery immediately changed its duration from normal to between 20 to 40 hrs and the capacity changed to 64984 mAh at full charge, of course the real life was lower than 2 hrs. T