Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 658
  • Last Modified:

FileReader from Java to c#

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
Rahamathulla_J
Asked:
Rahamathulla_J
  • 2
2 Solutions
 
AlexFMCommented:
0
 
anarki_jimbelCommented:
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
 
anarki_jimbelCommented:
I just wonder if this is a nice way to ask but give no points?   :)
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now