[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
- <!--x-content-type: text/plain -->
- <!--x-date: Thu Apr 8 21:28:19 2004 -->
- <!--x-from-r13: wgnlybe ng bayvarn.pbz (X.[. Fnlybe) -->
- <!--x-message-id: Pine.LNX.4.44.0404082139190.15631-[email protected] -->
- <!--x-reference: [email protected] --> "http://www.w3.org/TR/html4/loose.dtd">
- <!--x-subject: [ale] OT: java filereader question -->
- <li><em>date</em>: Thu Apr 8 21:28:19 2004</li>
- <li><em>from</em>: jtaylor at onlinea.com (J.M. Taylor)</li>
- <li><em>in-reply-to</em>: <<a href="msg00289.html">[email protected]</a>></li> FileReader fr = new FileReader("file1"); ^
- <li><em>subject</em>: [ale] OT: java filereader question</li>
This is the skeleton of the code I'm using...FileReader works fine inside
of main...there is definitely something major I'm missing here...
-----
import java.util.*;
import java.io.*;
public class mergesort
{
public static void main(String[] args) throws java.io.IOException
{
/*--snip---*/
doMergeSort(1,0,100);
}
public static void doMergeSort(int blsize, int fileset, double filesize)
{
if (blocksize < filesize/4)
{
FileReader fr = new FileReader("file1");
}
}
}
Thanks very much for looking at this...I'm afraid Java is still more than
a little bit of black magic to me right now.
jenn
On Thu, 8 Apr 2004, Denny Chambers wrote:
> First, what version of java are you using? (java -version)
>
> If you using Sun/IBM/Blackdown versions 1.1 or later, then this should work:
>
> String filename = (conditional ? "file1" : "file2");
> FileReader fr = new FileReader(filename);
>
> Now file1 and file2 should be a string representation of the relative or absolute path the files in question
>
> FileReader has a constructor FileReader(String fileName)
>
>
> Denny
>
>
>
> J.M. Taylor wrote:
>
> >Greetings all,
> >
> >I need to evaluate a condition and decide whether to open file1 or file2
> >based on that condition. Obviously I can do
> >if (conditional) {
> > FileReader fr = new FileReader("file1");
> >}
> >else {
> > FileReader fr = new FileReader("file2");
> >}
> >
> >However, with my undisciplined scripting language background I would like
> >to do something like
> >
> >File filename = (conditional ? "file1" : "file2");
> >FileReader fr = new FileReader(filename);
> >
> >I can do the ternary operator if I declare filename as a String, but then
> >FileReader won't open it (the parameter must be a File object).
> > new FileReader((File)filename)
> >doesn't work either.
> >
> >Nor does
> >FileReader fr = (conditional ? new FileReader("file1") : new
> >FileReader("file2"));
> >
> >Nor does
> >FileReader fr = new FileReader((conditional ? "file1" : "file2"));
> >
> >I don't use Java very much, but I like to understand what's going on (and
> >why I can and can't do things from language to language) as much as
> >possible. If anybody out there in aleland uses Java and can help me out,
> >I would greatly appreciate it. I won't be offended if you tell me why I'm
> >being brain-dead, if that is in fact the case.
> >
> >Thanks
> >jenn
> >
> >
> >
>
--
Jenn Taylor
jtaylor at onlinea.com
------------------------------------------------------------------------
Obviously, a man's judgement cannot be better than the information on which he
has based it. Give him the truth and he may still go wrong when he has
the chance to be right, but give him no news or present him only with distorted
and incomplete data, with ignorant, sloppy or biased reporting, with propaganda
and deliberate falsehoods, and you destroy his whole reasoning processes, and
make him something less than a man.
-- Arthur Hays Sulzberger
</pre>
<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<ul><li><strong>Follow-Ups</strong>:
<ul>
<li><strong><a name="00292" href="msg00292.html">[ale] OT: java filereader question</a></strong>
<ul><li><em>From:</em> dchambers at bugfixer.net (Denny Chambers)</li></ul></li>
</ul></li></ul>
<!--X-Follow-Ups-End-->
<!--X-References-->
<ul><li><strong>References</strong>:
<ul>
<li><strong><a name="00289" href="msg00289.html">[ale] OT: java filereader question</a></strong>
<ul><li><em>From:</em> dchambers at bugfixer.net (Denny Chambers)</li></ul></li>
</ul></li></ul>
<!--X-References-End-->
<!--X-BotPNI-->
<ul>
<li>Prev by Date:
<strong><a href="msg00290.html">[ale] OT: Legit</a></strong>
</li>
<li>Next by Date:
<strong><a href="msg00292.html">[ale] OT: java filereader question</a></strong>
</li>
<li>Previous by thread:
<strong><a href="msg00289.html">[ale] OT: java filereader question</a></strong>
</li>
<li>Next by thread:
<strong><a href="msg00292.html">[ale] OT: java filereader question</a></strong>
</li>
<li>Index(es):
<ul>
<li><a href="maillist.html#00291"><strong>Date</strong></a></li>
<li><a href="threads.html#00291"><strong>Thread</strong></a></li>
</ul>
</li>
</ul>
<!--X-BotPNI-End-->
<!--X-User-Footer-->
<!--X-User-Footer-End-->
</body>
</html>