Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

FileReader from Java to c#

Posted on 2006-07-11
6
Medium Priority
?
630 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

670 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