Results 1 to 6 of 6

Thread: Graphical interface for managing text files

  1. #1
    Join Date
    Dec 2009
    Posts
    192

    Graphical interface for managing text files

    Hello,
    I have a small question and I think this will interest you guys. I would like to create a graphical interface for managing text files or other, and also I want it to be platform independent. If you guys have any idea of how to do it then please I am the interested on here. I have one more question to ask you, normally we copy and paste a file if we want the same content of the file, is there any method or class which can do the same in java? If there is one the please let me know. Thanks in advance.

  2. #2
    Join Date
    Dec 2009
    Posts
    202

    Re: Graphical interface for managing text files

    Hello,
    Even I was trying a similar kind of a program, I have a code with me, this is what I was trying to do. See if this interests you. And also, if you have any alternative solution for this then you can post back. Thanks in advance.
    Code:
    Public class TextReader {
    	String pt =null;
    FileReader flrd =null;
    BufferedReader buf =null;
    	
    	
    	Public TextReader(String pt) throws FileNotFoundException{
    		this.pt= pt;
    flrd =new FileReader(pt);
    	}
     
    	Public void setPath(String pt) throws FileNotFoundException{
    		this.pt= pt;
    flrd = new FileReader(pt);
    buf =new BufferedReader(en);
    	}
     
    	Public String getPath(){
    		return this.pt;
    	}
     
    	Public void seeText() throws IOException{
    		String ln;
    buf =new BufferedReader(en);
    System.out.System.out.println("Start reading from file\ n==============================");
    		while((ln = buf.readLine())!=null){
    			System.out.print(row);
    		}
    		buf.close();
    System.out.System.out.println("\ n\ n");
    	}
     
    	Public String getText() throws IOException{
    		StringBuffer buff = null;
    String ln;
    buf =new BufferedReader(en);
    System.out.System.out.println("");
    		while((ln = buf.readLine())!=null){
    			buff.append(row);
    		}
    		buf.close();
    		return buff.function toString() {
        [native code]
    }();
    	}
     
    	Public static void hand(String args[]) throws IOException, FileNotFoundException{
    		TextReader t =new TextReader("Test");
    t.seeText();
    System.out.System.out.println(t.getText());
    		
    	}
    }

  3. #3
    Join Date
    Nov 2009
    Posts
    583

    Re: Graphical interface for managing text files

    Hello,
    I think for the stream you can reopen it every time, you should be firm when you do not need. For the problem of the number of copies, I think it is that you call 2 times online read.readLine = ();, in case you find an occurrence (once in the if, once after).
    Here is the code which demonstrates this

    Code:
    while(Online! =null)
    			{
     
    				if(row.games(".*"+ search +".*"))
    				{/ * if the line contains the searching * /
    					/ * Thanks to "regex": d * /
    					ctr + +;
    line = read.readLine();
    				}/ * if * /		       
    				line = read.readLine();
     
    			}

  4. #4
    Join Date
    Dec 2009
    Posts
    192

    Re: Graphical interface for managing text files

    Hello,
    This is the updated part of my code, please have a look at it
    Code:
    Public class Grep {
    
    String fl;
    String src;
    
    
    	Public Grep(String path, String s){
    		this.src= s;
    		this.fl= path;
    	}
     
    	int src(){
     
    		try{
    			FileReader stream = new FileReader(fl);
    BufferedReader read = new BufferedReader(flow);
    String ln = read.readLine();
    			int ctr =0;
    			while(Online! =null)
    			{
     
    				if(row.games(".*"+ src +".*"))
    				{/ * if the ln contains the searching * /
    					/ * Thanks to "regex": d * /
    					ctr + +;
    ln = read.readLine();
    				}/ * if * /		       
    				ln = read.readLine();
     
    			}
    			read.close();
    afloat.close();
     
    			return ctr;
    
    
    
    		}/ * try * /
    		catch (IOException e)
    		{
    			System.err.System.out.println("Malaise" + E.getMessage());
    System.exit(0);
    		}/ * catch * /
     
     
    		return 0;
     
    	}/ * src * /
     
    	Public static void hand(String args[]){
     
    		if(args.length<2){
    			System.out.System.out.println("Syntax: [fl] [src]);
    System.exit(0);
    		}
    
    G = grepnew Grep(args[0], args[1]);
    		int i = g.src();
    		if(i ==0){ 
    			System.out.System.out.println("This string does not appear" );
    System.exit(0);
    		}
     
    		if(i ==1){
    			System.out.System.out.println("This string appears once" );
    System.exit(0);
    		}
    		System.out.System.out.println("This string appears in" + + Nb "example" );
     
    	}
    	
    }

  5. #5
    Join Date
    Nov 2009
    Posts
    356

    Re: Graphical interface for managing text files

    Hello,
    I have updated your code, have a look at it
    Code:
    public class TextReader {
    	String pt =null;
    FileReader flrd =null;
    BufferedReader buf;
    
    
    	Public TextReader(String pt) throws FileNotFoundException{
    		this.pt= pt;
    flrd =new FileReader(pt);
    	}
     
    	Public void setPath(String pt) throws FileNotFoundException{
    		this.pt= pt;
    flrd = new FileReader(pt);
    	}
     
    	Public String getPath(){
    		return this.pt;
    	}
     
    	Public void openBuffer(){
    		buf =new BufferedReader(en);
    	}
     
    	Public void closeBuffer() throws IOException{
    		buf.close();
    	}
     
    	Public void seeText() throws IOException{
    		String line;
    openBuffer();
    System.out.System.out.println("start");
    		while((line = buf.readLine())!=null){
    			System.out.print(row);
    		}
    		System.out.System.out.println("\ n\ n");
    closeBuffer();
    	}
     
    	Public String getText() throws IOException{
    		String s;
    openBuffer();
    StringBuffer buff =new StringBuffer();
    buff =null;
    System.out.System.out.println("Reopening");
    		while( (l = buf.readLine() )!=null){
    			buff.append(l);
    		}
     
    		return  buff.function toString() {
        [native code]
    }();
    	}
     
    	Public static void hand(String args[]) throws IOException, FileNotFoundException{
    		TextReader t =new TextReader("Test");
    t.seeText();
    System.out.System.out.println("Res"+ t.getText());
    	}
    }

  6. #6
    Join Date
    Nov 2009
    Posts
    333

    Re: Graphical interface for managing text files

    Hello,
    When you close the BufferedReader, FileReader the associated with it is also closed. So after running the method seeTextThe FileReader is closed and consequently the method seeText () can not be excuted. Other comments: In your method getText () You created a StringBuffer and then assign null. If you need more information on this then you can visit the sun's official site and there you can find a detailed information on this.

Similar Threads

  1. Maxthon graphical Interface
    By Omanand in forum Technology & Internet
    Replies: 5
    Last Post: 29-06-2011, 06:16 AM
  2. Managing Files with VBScript
    By Monty1 in forum Software Development
    Replies: 2
    Last Post: 14-12-2010, 12:36 AM
  3. Better Graphical User Interface : Linux or Mac OS X?
    By Rudra.J in forum Polls & Voting
    Replies: 3
    Last Post: 16-10-2009, 09:13 AM
  4. Download a DOS clone which has Graphical User Interface
    By Bracken in forum Operating Systems
    Replies: 2
    Last Post: 09-03-2009, 12:06 PM
  5. Replies: 5
    Last Post: 22-12-2007, 07:52 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,901,878.23642 seconds with 17 queries