Reading a text file from a remote host. Authentication required.

Hi frnds,
I have to read a text file "config.txt" from a remote host "HOSTNAME". File is shared in a folder - "FOLDER" .
If the folder is shared with no password protection then it works. But if the folder is password protected the code is unable to read the file.
I know the UserName and PassWord of the shared folder. How to code for this.
I don't want to share the Folder to everyone without a password.
Kindly Help.
try {
FileReader fr=new FileReader("\\\\HostName\\folder\\config.txt");
BufferedReader br=new BufferedReader(fr);
String s=null;
while((s=br.readLine())!=null)
/* One line is read */
fr.close();
catch(Exception e)
throw new Exception("Exception in ConfigConstants."+e.toString());
urs
Mishra

ok.. let me define it clearly...
By using ftp as a protocol how can I read a text file
in remote machine........ kindly do reply....Have a look at this article:
http://www.javaworld.com/javaworld/jw-04-2003/jw-0404-ftp.html
and what are the prerequisities that are needed for
such a type of operation.....(At least) an FTP server should be running on the machine where the text file resides.
Message was edited by:
prometheuzz
Oh, you should have your keyboard fixed: the full stop key seems to be stuck, you have a lot of trailing ..... after each sentence.

Similar Messages

  • Reading a text file from a URL

    I am having problems trying to read a text file from a URL.
    This is the code i have been using:
    package Java;
    import java.net.*;
    import java.io.*;
    public class Main_1 {
    public static void main(String[] args) throws Exception {
         URL myAddress = new URL("http://www.geocities.com/simonrobinson1/java/farrago.txt");
         BufferedReader in = new BufferedReader(
                        new InputStreamReader(
                        myAddress.openStream()));
         String inputLine;
         while ((inputLine = in.readLine()) != null)
         System.out.println(inputLine);
         in.close();
    but it returns an error saying:
    java.net.NoRouteToHostException: Operation timed out: no further information
    at java.net.PlainSocketImpl.socketConnect(Native Method) .....etc etc.
    Is this just a problem due to my network or is there something wrong with my code ????

    Altho you can access the file by typing the URL in a browser, geocities being a free web-hosting service don't like you to access the materials without seeing their ads. You have to find a way to trick it into thinking that you are indeed coming in from a web browser even tho you aren't.
    V.V.

  • Read a text file from DB directly (don't use PLSQL).

    how can I Read a text file from DB directly (don’t use PLSQL). ?

    If there is a known structure, you could use External Table access and query that "file" as any table.
    Nicolas.

  • How to read a text file from a Jar file

    Hi
    How can I read a text file from a Jar file?
    Thanx in advance..

    thanx
    helloWorld it works.damn, I didn't remove it fast enough. Even if it is urgent, it is best not to mention it, telling people just makes them take longer.

  • Sample code to read a text file from UNIX directory.

    I am using 9i Developer Suite, application server is 9.0.4. I want some help on how to read a flat file from UNIX environment. A sample code could be very helpful.
    In windows, i use this kind of code:-
    I declare an object & then write to a file using these sample staements:-
    file_handle text_io.file_type;
    filename := 'd:\ran\egs\uninvoiced.txt';
    file_handle:=text_io.fopen(filename,'w');
    text_io.put_line(file_handle, 'MOBILE NO '||'COUPON NO ' || 'DATE');
    I hope, my question is clear. Please help in solving the doubt.
    Regards.

    filename := 'd:\ran\egs\uninvoiced.txt';This is a Windows directory, so it won't work on Unix.
    For the rest of the code: see examples in the Forms Builder Online Help.

  • Reading a text-file from within a Jar-file...

    I've made a program, that reads from a text-file. And it works great. But when I try to put the program into a jarfile, I get a fileNotFoundException... I have the textfile both inside and outside the jarfile... with the same result.
    Does anyone know what I might be doing wrong?
    Thanx in advance!
    Martin

    Depends on the path you enter for the text file. If you simply put "filename.txt" then you should try to have the file in the same directory as the class which accesses the file.
    Cheers,
    H�vard

  • Trying to write an applet that reads/displays a file from a remote server

    Hey all,
    I'm trying to make a little applet that launches from a browser that allows me to read a file from a server, reads it line by line and displays each line, and continues to read/monitor the file until I get a specific line of text.
    I've tried to do some code and although I can read the file (and display it), I can't seem to detect the end string (the if statement that tests if the line == "--END--" seems to have no effect, i.e. constant false).
    I have a feeling the approach I took is wrong since this seems insecure and just looks bad (I've seen stuff that seems to indicate I need to do something with implements Runnable or something.) Even if anyone doesn't have the time to actually do the framework of this, if they could perhaps outline an approach and any necessary topics I need to look at (such as
    1. Go and read the threads tutorial.
    2. Go and read the X section in the Y tutorial.
    3. Check out this <link>, as they seem to be doing something similar to what you're doing.
    Thanks in advance.
    import java.util.*;
    import java.io.*;
    import javax.swing.*;
    import java.awt.*;
    import java.net.*;
    public class FaxTest extends JApplet {
         JTextArea area;
         JScrollPane pane;
         String display;
         String old_display;
         String tmp;
         boolean end = false;
         java.util.Timer FileTimer = new java.util.Timer();
         TimerTask FileReadTask = new readFile();
         public void init() {
              area = new JTextArea();
              area.setWrapStyleWord(true);
              area.setLineWrap(true);
              area.setEditable(false);
              pane = new JScrollPane(area);
              Container c = getContentPane();
              c.add(pane);
              FileTimer.schedule(FileReadTask, 500,5000);
         public void stop()
              FileTimer.stop();
         class readFile extends TimerTask {
              public void run() {
              java.util.Timer timer = new java.util.Timer();
              TimerTask task = new FaxUpdate();
              timer.schedule(task, 1000,1000);
              try {
              display = "";
              String filename = getParameter("FILENAME");
              URL url = new URL(filename);
              InputStreamReader in = new InputStreamReader(url.openStream());
              BufferedReader br = new BufferedReader(in);
              while( (tmp = br.readLine()) != null) {
                   if (tmp == "--END--\n") end = true;
                   display += tmp;
              catch(IOException error) {
              display = "Error" + error;
         class FaxUpdate extends TimerTask {
              public void run() {
              if(end == true) {
                   area.setText("finito");
              else area.setText(display);
    }

    use tmp.equals("--END--\n") instead of tmp == "--END--\n"
    The == means does tmp reference the same object as "--END--\n" which will probably never be true. Using the equals method means does tmp contains the same characters as "--END--\n"

  • How to read a text file from other machine???

    I have a text file located in local machine. I use th e code below to retrieve data from that particular text file.
    String realPath     = (String)getServletContext().getRealPath("");
    BufferedReader holsFile = new BufferedReader(new FileReader(realPath + "/webpages/holidays.txt"));My question is , how could I retrieve the records from the tsxt file if the file is located in another machine or webserver?
    Thanks for advanced.

    It's ok to be new.
    The answer is yes. (But I'll let you look in the javadoc to see which package it's in).
    Also it may be worth understanding that there is no such thing as a "function" in java, operations are termed "methods". To go further, you should realise that URL is a class not a "function" or method. The parentheses mean you're calling the constructor.
    HTH
    /k1

  • How to read a text file from Visual Composer

    Hi VC Experts,
    Please suggest me how can we read a textfile from  the local machine and pull the data from Visual Composer.
    Regards
    Kiran

    Hy kiran, is not possible to read data from flat file and put it in visual composer but you can :
    1) load this file in BI by ETL, for example on DSO object and then you can create a bex query to retrive the data
    2) if you want display the content of this file , you can use KM.
    Regards,
    Andrea

  • Getting error when reading xml file from a remote connection

    Hi all,
    I want to read an xml file from a remote connection, not from my local machine.So when i am creating the data server i am giving the host name(that is the ip of the machine where the xml file is located), giving the proper username and password and giving the path of the xml file. When i am testing the connection the error that is coming:- "Connection failed and the xml file could not be created, verify that you have write permission in the directory"...
    but read write and execute permissions have been given on the directory as well as to the file...
    Regards,
    Sourav

    Hi Sutirtha,
    Initially I have started the agent.sh giving the agent name <agent name>and port number 20910 and defined it in the topology manager it is showing that the agent test is succesful. Then I tested a particular Data server against that agent and the test was successful.
    After this we had stopped the agent and restarted it.
    However now suddenly the testing against the remote agent is failing with the following excep:
    java.lang.Exception:
         at com.sunopsis.graphical.l.pm.a(pm.java)
         at com.sunopsis.graphical.l.pm.s(pm.java)
         at com.sunopsis.graphical.l.pm.g(pm.java)
         at com.sunopsis.graphical.l.pm.a(pm.java)
         at com.sunopsis.graphical.l.pm.a(pm.java)
         at com.sunopsis.graphical.l.iz.actionPerformed(iz.java)
         at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
         at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Unknown Source)
         at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
         at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
         at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
         at java.awt.Component.processMouseEvent(Unknown Source)
         at java.awt.Component.processEvent(Unknown Source)
         at java.awt.Container.processEvent(Unknown Source)
         at java.awt.Component.dispatchEventImpl(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Window.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.EventQueue.dispatchEvent(Unknown Source)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
         at java.awt.Dialog$1.run(Unknown Source)
         at java.awt.Dialog.show(Unknown Source)
         at java.awt.Component.show(Unknown Source)
         at java.awt.Component.setVisible(Unknown Source)
         at com.sunopsis.graphical.l.pm.q(pm.java)
         at com.sunopsis.graphical.l.pm.<init>(pm.java)
         at com.sunopsis.graphical.frame.b.jh.bx(jh.java)
         at com.sunopsis.graphical.frame.bo.w(bo.java)
         at com.sunopsis.graphical.frame.bo.d(bo.java)
         at com.sunopsis.graphical.frame.w.actionPerformed(w.java)
         at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
         at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Unknown Source)
         at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
         at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
         at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
         at java.awt.Component.processMouseEvent(Unknown Source)
         at java.awt.Component.processEvent(Unknown Source)
         at java.awt.Container.processEvent(Unknown Source)
         at java.awt.Component.dispatchEventImpl(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Window.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.EventQueue.dispatchEvent(Unknown Source)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.run(Unknown Source)
    PS: do i have to modify any file after or before starting the odi agent
    Thnks and Rgds,
    Sourav
    Edited by: user13263578 on Mar 15, 2011 9:35 PM
    Edited by: user13263578 on Mar 15, 2011 9:48 PM

  • Reading text file from database server in OA Page

    Hi Guys,
    I am trying to embed an applet with in an OA Page. The applet is used to mainly for showing Gantt chart. I have to pass my connection details from OA Page to applet, I dont pass directly the connection details to the applet so i am placing all the server details, user name and password in a text file on the database server.
    So from the OA Page i have to read the contents of the file on the database server and pass them to the applet using the <PARAM> tag. My question is how to read the text file from the database server.Any Inputs?
    Thanks in advance for your help.
    Regards,
    Nagesh Manda.

    If the file to be read is on the database, then it makes sense to use the pl/sql code to read the file. Make a call to this pl/sql code from page controller to get back the values.
    --Shiv                                                                                                                                                                                                                                                                                                                                                                                           

  • How to download a text file from the server

    hi everyone,
    can anyone tell me how to download and read a text file from the server and saved in into resource folder.
    with regards
    pallavi

    its really easy
    To read from server, use something like:
    HttpConnection connector = null;
    InputStream inp_stream = null;
    OutputStream out_stream = null;
    void CloseConnection()
         if(inp_stream!=null)inp_stream.close();
         inp_stream=null;
         if(out_stream!=null)out_stream.close();
         out_stream=null;
         connector.close();
         connector = null;
    public void getResponse(String URL,String params)
      try
         if(connector==null)connector = (HttpConnection)Connector.open(URL);//URL of your text file / php script
         connector.setRequestMethod(HttpConnection.POST);
         connector.setRequestProperty("User-Agent","Profile/MIDP-2.0 Configuration/CLDC-1.1");
         connector.setRequestProperty("content-type", "application/x-www-form-urlencoded");
         //connector.setRequestProperty("charset","windows-1251");
         //*** If you need to send ("arg1=value&arg2=value") arguments to script use this:
         out_stream = connector.openOutputStream();
         byte postmsg[] = params.getBytes();
         out_stream.write(postmsg);
         int rc = connector.getResponseCode();//in any case here connection will be opened & closed
         if (rc != HttpConnection.HTTP_OK)
              CloseConnection();
              throw new IOException("HTTP response code: " + rc);
         inp_stream = connector.openInputStream();
         int pack_len = inp_stream.available();
         byte answ[]=new byte[pack_len];
         inp_stream.read(answ);
         CloseConnection();
         ProcAnswer(answ);//process received data
      catch(Exception ex)
         System.err.println("ERROR IN getResponse(): "+ex);
    } And you can read from resource file like
    public void loadFile(String filename)
        DataInputStream dis = new DataInputStream(getClass().getResourceAsStream("/"+filename));
        String str="";
        try
             while (true)
                ch = dis.read();//read character
                if(ch=='\r')continue;//if file made in windows
                if(ch=='\n' || ch==-1)//end of line or end of file
                    if(str.length()==0)continue;//if empty line
                    //do some thing with "str"
                    if(ch==-1)break;//it was last line
                    str="";//next line
                    continue;
                 str+=(char)ch;
           dis.close();
       catch (Exception e)
           System.err.println("ERROR in loadFile() " + e);
    }Welcome! =)
    Edited by: MorskoyZmey on Aug 14, 2008 3:40 AM

  • How do I read and write to text files on a remote computer's hard drive

    I would like to read and write data to a text file on a remote computer. This is easily accomplished using one of the file functions such as "write characters to file.vi". If I am already connected to the remote computer, all I need to do is specify the path to the particular file and it will work fine.
    My problem is that I want to connect to the remote computer programatically within LabVIEW (I do not want to have to use the computer's OS to establish the connection. Is there a function that I can use to do this?
    Thomas D. Schaefer
    Wells Manufacturing Corp

    Yariv,
    You should really start a new thread with a new question like this, so that more people see it. Some people look primarily at threads that have no responses yet. Also, don't post the exact same question in multiple places. Or, if you must cross-post to some other forum, make sure to mention it in your question text.
    I'm happy to be a brick in your Western Wall, but I'm not sure what the main objective is here. Is the main problem really getting access to the "X bytes received in Y seconds at Z bytes/sec" string? Or is it accomplishing the file transfer? And what OS and LabVIEW version are you running?
    I think your problem is that you the LabVIEW System Exec command does not allow for the degree of interactivity that you need if you want to issue a sequence of commands to a command-line executable. However, under Windows XP (and, presumably, other Windows versions, though I can't check), you can tell the FTP executable to use commands from a textfile script by using the -s switch, and you can override the prompts during multiple file transfers with the -i switch:
    ftp -i -s:FILEPATH SERVERNAME
    If you issue a command in this format to System Exec, and make sure to create a file at FILEPATH with your command sequence (one per line), then you should at least accomplish the FTP actions. This won't give you the transfer details in the standard output, unfortunately. However, if you just want a general sense of how much was transferred and how quickly it happened, you can code that in LabVIEW by getting the resulting file sizes and using Tick Count before and after the System Exec call to see how long the transfer took.
    Hope that helps,
    John

  • What are some of the best iOS apps can remotely played videos, audios, photos and text files from a NAS hdd connected to Airport Extreme USB port? And how to configure this setup?

    I have already set up NAS hdd as connecting it at USB port of Airport Extreme, i also want to remotely access it from iPhone, so what's the next step? What are some of the best iOS apps can remotely played videos, audios, photos and text files from the NAS hdd and how to configure this setup?

    *Edit - I am not able to connect to the NAS when hardwired to the airport extreme.

  • From an Oracle form, I want to read a text file.

    From an Oracle form, I want to read a text file. In the form on a button press I have:
    declare
    in_file Text_IO.File_Type;
    linebuf VARCHAR2(1800);
    filename VARCHAR2(30);
    BEGIN
    filename:=GET_FILE_NAME('U:\ora_devl\pps\work\a.txt', File_Filter=>'Text Files (*.txt)|*.txt|');
    in_file := Text_IO.Fopen(filename, 'r');
    LOOP
    Text_IO.Get_Line(in_file, linebuf);
    -- :text_item5:=:text_item5||linebuf||chr(10);
    Text_IO.New_Line;
    END LOOP;
    EXCEPTION
    WHEN no_data_found THEN
    Text_IO.Put_Line('Closing the file...');
    Text_IO.Fclose(in_file);
    END;
    It gets an ORA-302000. I suspect the problem starts with the GET_FILE_NAME because when I comment out everything but that, It processes endlessly never ending.
    Forms [32 Bit] Version 11.1.1.3.0 (Production)
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    What can you tell me? Thanks

    GET_FILE_NAME will try to open an "Open File" dialog on the server, which obviously can't happen. If you want to use that type of behavior you need to use WebUtil and the function CLIENT_GET_FILE_NAME. Example:
         filename := CLIENT_GET_FILE_NAME('C:\', File_Filter=> 'Text Files (*.txt)|*.txt|All Files (*.*)|*.*|', dialog_type=> OPEN_FILE);Refer to the Builder Online help for more details. You can also refer to the demo which is available here:
    http://www.oracle.com/technetwork/developer-tools/forms/downloads/index.html
    More information here:
    http://www.oracle.com/technetwork/developer-tools/forms/webutil-090641.html
    Also, it appears that you are attempting to use a mapped drive ("U"). Although this can be made to work, it is not recommended and in some cases will not be supported. If you need access to remote files, you should use some other mechanism to bring the file to the local machine before manipulating it.

Maybe you are looking for