Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How can I....  RSS feed

 
Manuel Diaz
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have this code:

TextReader inFile = new TextReader("something.txt");


but the program don't recognize 'TextReader'. What library do I need in here?
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's a common class by that name in C#, but not in Java. A java.io.BufferedReader wrapping a FileReader is probably the closest Java equivalent:

BufferedReader reader = new BufferedReader(new FileReader("something.txt"));
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!