Results 1 to 2 of 2
  1. #1
    jforce93 is offline Member
    Join Date
    Aug 2009
    Rep Power

    Default 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 in my project to get user input. Here is my code:

    import java.util.Scanner;

    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);

    Any help please??

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Blog Entries
    Rep Power


    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

  1. How to convert a string into a BigInteger
    By valery in forum New To Java
    Replies: 4
    Last Post: 09-13-2011, 02:32 PM
  2. Replies: 1
    Last Post: 01-06-2011, 06:35 AM
  3. Convert Comparable object to string or char
    By ScKaSx in forum New To Java
    Replies: 4
    Last Post: 01-25-2009, 03:02 PM
  4. Convert Linked List Object element to String
    By CirKuT in forum New To Java
    Replies: 2
    Last Post: 12-13-2008, 06:22 AM
  5. Can't convert java.lang.String to int.
    By Albert in forum AWT / Swing
    Replies: 2
    Last Post: 07-13-2007, 06:05 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts