Results 1 to 2 of 2
- 08-09-2009, 09:24 PM #1
Member
- Join Date
- Aug 2009
- Posts
- 24
- Rep Power
- 0
convert a string to an object in java
okay so im trying to make something that takes the user input, and sets it as the name of the file i am trying to access. I am using EasyInput.java in my project to get user input. Here is my code:
import java.util.Scanner;
import java.io.*;
public class Main
{
public static void main(String[] args) {
String title = EasyInput.getln();
String title2 = title + ".txt";
FileReader someFile = new FileReader(title2);
BufferedReader input = new BufferedReader(someFile);
System.out.print(input);
}
}
Any help please??
-
You need to have your buffered reader read something for this to work. You may wish to use a while loop, read your input string from the buffered reader in the boolean condition of the while loop, and if not null, println the string read in. Your text book or the Sun tutorial can give you more details here.
Similar Threads
-
How to convert a string into a BigInteger
By valery in forum New To JavaReplies: 4Last Post: 09-13-2011, 01:32 PM -
how to convert a xml to java object in J2ME
By vogash in forum XMLReplies: 1Last Post: 01-06-2011, 05:35 AM -
Convert Comparable object to string or char
By ScKaSx in forum New To JavaReplies: 4Last Post: 01-25-2009, 02:02 PM -
Convert Linked List Object element to String
By CirKuT in forum New To JavaReplies: 2Last Post: 12-13-2008, 05:22 AM -
Can't convert java.lang.String to int.
By Albert in forum AWT / SwingReplies: 2Last Post: 07-13-2007, 05:05 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks