daarkfall's Profile User Rating: -----

Reputation: 1 Apprentice
Group:
New Members
Active Posts:
15 (0.01 per day)
Joined:
27-August 09
Profile Views:
1,232
Last Active:
User is offline Oct 19 2013 12:19 PM
Currently:
Offline

Previous Fields

Country:
GB
OS Preference:
Linux
Favorite Browser:
Chrome
Favorite Processor:
AMD
Favorite Gaming Platform:
PC
Your Car:
Nissan
Dream Kudos:
0

Latest Visitors

Icon   daarkfall has not set their status

Posts I've Made

  1. In Topic: File input and File output java promblems

    Posted 15 Jul 2013

    This is how i would do it, define the file and then pass it to a file reader, then finally use a buffered reader to parse the file.

    From there create a while loop which assigns the line to a predetermined string value and asserts that the line is not null (End of the file)
    finally close the buffer

    import java.io.BufferedReader;
    import java.io.File;
    import java.io.FileReader;
    import java.io.IOException;
    
    
    public class Test {
    
    	public static void main(String[] args)
    	{
    		try{
    		File file = new File("usernames.txt"); // define the file
    		FileReader fileReader = new FileReader(file); // select the reader module
    		BufferedReader br = new BufferedReader(fileReader); //define the type of reader
    			
    
    		String s = "";
    		while((s = br.readLine())!= null) //assign the next line
    		{
    			printMethod(s); //call your method 
    		}
    		br.close(); // close the stream
    		
    		}catch (IOException IOE)
    		{
    			IOE.printStackTrace();
    		}
    		
    	}
    	
    	private static void printMethod(String method)
    	{
    		System.out.println(method);
    	}
    }
    
    
    



    Hope this helps ~ Daark
  2. In Topic: How do I store text?

    Posted 3 Feb 2013

    http://heather.cs.ucdavis.edu/~matloff/Java/JavaIntro.html
    

    Here is a relatively good introduction to java.

    I would also recommend the text book head first with java
     http://www.amazon.co.uk/Head-First-Java-Kathy-Sierra/dp/0596009208 
    


    Both are excellent resources for getting into grips with the basics of java programming :)/>

    But essentially what you are actually looking for (so as to be of some use)

    is
    
    String x = " hello world "; //the string object is the most basic form of handling text in java
    char [] x_two = {'h','e','l','l','o',' ', 'w','o','r','l','d'}; //similar to C you can also treat text as a character //array, 
    
    //Strings can also be transformed into character arrays 
    x_two = x.toCharArray(); // its something like that i am not on my development machine at the moment
    
    
    


    Hope this helps dude

    ~Daark

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:
Interests:
Gaming, Music

Contact Information

E-mail:
Private

Friends

daarkfall hasn't added any friends yet.

Comments

daarkfall has no profile comments yet. Why not say hello?