Results 1 to 7 of 7
  1. #1
    one198 is offline Member
    Join Date
    Aug 2007
    Posts
    15
    Rep Power
    0

    Default Offline Web browser

    Hi guys

    I developing software something like offline web browser(Teleport pro).in here what iam doing is using bufferereder i get contents of web page into reader and save it in to text file.but it give error message.

    pls help me

    Thank you

    Java Code:
    import java.net.*;
    import java.io.*;
    import java.nio.channels.FileChannel;
    
    public class Test {
    
    public   void main(String[] args) throws Exception {
    
    String text[];
    File aFile = new File("D:\\Java\\First.text");
    FileOutputStream outputFile = null;
    
          try{
           outputFile = new FileOutputStream(aFile);
              }  catch(FileNotFoundException e)
              {
    
                e.printStackTrace(System.err);
            }
                    FileChannel outputChannel = outputFile.getChannel();
    
            URL yahoo = new URL("http://www.yahoo.com");
            URLConnection yc = yahoo.openConnection();
            BufferedReader in = new BufferedReader(
                                    new InputStreamReader(
                                    yc.getInputStream()));
            String inputLine;
            outputChannel.write(in);
     in.close();
    }
    }
    Last edited by levent; 08-02-2007 at 10:13 AM. Reason: Code is placed inside [code] tag.

  2. #2
    levent Guest

    Default

    What is the error message?

  3. #3
    one198 is offline Member
    Join Date
    Aug 2007
    Posts
    15
    Rep Power
    0

    Default Offline web browser

    hi guys

    iam using IntellijIDE for write java codings,once i complie above codings its gives error message as below

    Error(39,1),can not find symbol method write(java.io.bufferedReader)

    pls help


    Thank you
    Last edited by one198; 08-02-2007 at 11:55 AM.

  4. #4
    levent Guest

    Default

    There error is reporting this line:

    Java Code:
    outputChannel.write(in);
    outputChannel is an instance of FileChannel. Check javadoc of FileChannel here. It does not have a write method which has a BufferedReader parameter as reported in this error. You should send an instance of ByteBuffer to that method.

  5. #5
    one198 is offline Member
    Join Date
    Aug 2007
    Posts
    15
    Rep Power
    0

    Default

    Dear levent


    once i change my coding like below it gives error message.
    Error ByteBuffer is abstarct class and u cant create instance Bytebuffer.

    I dont know much about these topics.

    pls help

    coding

    ByteBuffer xc=new ByteBuffer(new InputStreamReader(yc.getInputStream()));

    Thank you

  6. #6
    levent Guest

    Default

    It seems that you can not create a bytebuffer like that. Read the javadoc please, it says you can create a bytebuffer allocating or wrapping.

    I recommend you to use the downloadPage() method in the following example:

    Java Tips - How to create a Search Crawler in Java

    It shows a clear way of doing this. And since you will need to create some ind of crawler to download all pages on a web site, other methods might help you too.

    downloadPage method in that example downloads a web page and returns it as a string. In your case, you can save the returned string to the disk or create your own method based on that example.

  7. #7
    one198 is offline Member
    Join Date
    Aug 2007
    Posts
    15
    Rep Power
    0

    Default Offline web browser

    Dear levent

    Thank your for advices.I think ur web page is usefull for me.

    Thank you bro

Similar Threads

  1. Need Help! swt/Browser
    By sealyu in forum SWT / JFace
    Replies: 4
    Last Post: 07-09-2008, 08:16 PM
  2. connect JDBC to offline database
    By nancyhung in forum JDBC
    Replies: 1
    Last Post: 04-11-2008, 11:04 PM
  3. how to get url from browser
    By srinivas reddy in forum New To Java
    Replies: 0
    Last Post: 02-08-2008, 07:46 AM
  4. how to redirect the browser
    By simon in forum Java Applets
    Replies: 1
    Last Post: 08-02-2007, 05:24 PM

Posting Permissions

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