[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Importing .txt files

Posted on 2004-04-23
9
Medium Priority
?
285 Views
Last Modified: 2010-04-01
I am trying to import .txt files using jsp, i have created a table and want one each in each cell, i'm not sure of the commands i need to import them, and also to save them again (which will be needed later) thanks.
0
Comment
Question by:megakingbob
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
9 Comments
 
LVL 6

Expert Comment

by:jkna_gunn
ID: 10898149
are you talking about a jtable? or a database table?

what is in the textfile? is it delimited records? or will it need to be parsed?
0
 

Author Comment

by:megakingbob
ID: 10898211
just a <table> in a webpage, it's just text no parsing is necessary.
0
 
LVL 35

Accepted Solution

by:
TimYates earned 2000 total points
ID: 10898248
<table>
  <tr>
    <td>

<%
    java.io.BufferedReader br = null ;
    try
    {
        br = new java.io.BufferedReader( new java.io.FileReader( "/files/text.txt" ) ) ;
        String line ;
        while( ( line = br.readLine() ) != null )
            out.println( line ) ;
    }
    catch( java.io.IOException ex )
    {
        out.println( ex.toString() ) ;
    }
    finally
    {
        try { if( br != null ) br.close() ; } catch( java.io.IOException ex ) {}
    }
%>

    </td>
  </tr>
</table>
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 35

Expert Comment

by:TimYates
ID: 10898254
Assuming your text file is on the server in the "/files" directory (off the root)
0
 

Author Comment

by:megakingbob
ID: 10898346
it works but can i use relative addressing instead of fixed for the location of the text file.
0
 
LVL 35

Expert Comment

by:TimYates
ID: 10898494
You need to work out what the current working directory is...

try

<%
  out.println( "CWD: " + new java.io.FIle( "." ).getAbsolutePath() ) ;
%>

That should show you the working directory, then relative directories should be able to be used relative to that...

I hope ;)
0
 
LVL 35

Expert Comment

by:TimYates
ID: 10898560
FIle

should be

File

of course :)
0
 

Author Comment

by:megakingbob
ID: 10898657
thanks very much, its only because its going onto another server but i'll alter it again when it's on that server with the help you provided thanks again :-)
0
 
LVL 35

Expert Comment

by:TimYates
ID: 10898668
:-)  Hope it works!  (It should do)

Good luck with it!!

Tim
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here in this article, you will get a step by step guidance on how to restore an Exchange database to a recovery database. Get a brief on Recovery Database and how it can be used to restore Exchange database in this section!
As much as Microsoft wants to kill off PST file support, just as they tried to do with public folders, there are still times when it is useful or downright necessary to export Exchange mailboxes to PST files. Thankfully, it is still possible to e…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question