Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

FileReader from Java to c#

Posted on 2006-07-11
6
Medium Priority
?
642 Views
Last Modified: 2012-06-27
How can i convert the below c# code into equivalent c# code


//  Load the string that holds the XML for from-string parsing
        FileReader fileReader = new FileReader(file);
        int numChars = (int) file.length();
        char[] dataArr = new char[numChars];
        fileReader.read(dataArr, 0, numChars);
        fileReader.close();
0
Comment
Question by:Rahamathulla_J
  • 2
6 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 500 total points
ID: 17081768
0
 
LVL 30

Assisted Solution

by:anarki_jimbel
anarki_jimbel earned 500 total points
ID: 17085846
If you need just a string from a file:

           StreamReader reader = new StreamReader("myfile.txt");
            String result = "";
            String line;
            // Read and display lines from the file until the end of
            // the file is reached.
            while ((line = sr.ReadLine()) != null)
            {
                result+=line;
            }

Of course, use try-catch etc. StringBuilder is better to use - I used string for simplicity..
0
 
LVL 30

Expert Comment

by:anarki_jimbel
ID: 17315071
I just wonder if this is a nice way to ask but give no points?   :)
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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

916 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