Solved

FileReader from Java to c#

Posted on 2006-07-11
6
604 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 125 total points
ID: 17081768
0
 
LVL 29

Assisted Solution

by:anarki_jimbel
anarki_jimbel earned 125 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 29

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

895 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now