Solved

FileReader from Java to c#

Posted on 2006-07-11
6
613 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone 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

Suggested Solutions

Title # Comments Views Activity
compare between entities in entity framework 8 93
What can cause the styling on a .NET site to not be found? 17 29
C# Gridview 1 47
bound data table problem 2 33
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

839 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