0

Read txt file

asked 2011-05-23 11:09:36 +0800

kikeskate gravatar image kikeskate
261 2

Hi there ...

im trying to implement my code with the zul to read my txt file, but im having problems to make it work could anyone tell me what im doing wrong.

Thanks

<?page title="texto" contentType="text/html;charset=UTF-8"?>
<zk>
<window title="texto" border="normal">

	<grid>		
				<rows>
					 
					<row align="center">
						<label value="Name of the log file" />
					 	<label value = "" id = "name_log"/>
					</row>
				
					<row align="center">
						<label value = "Last update "/>
						<label id = "l_update" />
					</row>		
					
					<row  align="center">
							
							<button label=" Process " width="90px" id = "" onClientInfo="" onClick="show()"/>
							
					</row>

			</rows>
				
		</grid>
		
		
		<grid>
		
			<rows>
				
				<row align="center">
				
					<vlayout>
						<label value = "Aca van ultmas 20 lineas"/>
						<label value = "Aca van ultmas 20 lineas"/>
						<label value = "Aca van ultmas 20 lineas"/>
						<label value = "Aca van ultmas 20 lineas"/>
						<label value = "Aca van ultmas 20 lineas"/>
						<label value = "Aca van ultmas 20 lineas"/>
						<label value = "Aca van ultmas 20 lineas"/>
					</vlayout>
				
				</row>
					
			</rows>
		
		</grid>

</window>

<zscript><![CDATA[
                  
   import java.io.*; 
   
   public class ReadFile
   {
	   public void show(){
	   {
	   
		   try{
			   
			   FileInputStream fstream = new FileInputStream ("texto.txt");
			   
			   DataInputStream in = new DataInputStream (fstream);
			   
			   BufferedReader br = new BufferedReader (new InputStreamReader(in));
			   
			   String strLine;
			   
			   while ((strLine = br.readLine()) != null ) {
				   
				   System.out.println(strLine);
				   
			   }
			   
			   in.close ();
			   
		   }catch (Exception e) {
			   
			   System.err.println("Error" + e.getMessage());
			   
			   }
		   }
	   
   }
   
   
                  
                  ]]></zscript>

</zk>

delete flag offensive retag edit

3 Replies

Sort by ยป oldest newest

answered 2011-05-25 06:45:47 +0800

Steva77 gravatar image Steva77 flag of Italy
1014 3
http://www.research.softe...

Mmmh... you simply call show() but you have a complete "nested/inner" class defined there.
Is it meant to work like this? In tutorials there are examples on how to include functions on the fly in .zul pages.
And take care where are you taking the file texto.txt from (i.e. its position on the file system) - this way I think it must be at the same level of your .zul file.

link publish delete flag offensive edit

answered 2011-05-25 10:50:36 +0800

kikeskate gravatar image kikeskate
261 2

Steva77 Maybe you can send me a link. About my txt acttually is add to me package.

Thanks

link publish delete flag offensive edit

answered 2011-05-26 01:32:32 +0800

woodyki gravatar image woodyki
168

It is easy to make a object instance of the class ReadFile inside the zscript then call show() method.

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2011-05-23 11:09:36 +0800

Seen: 408 times

Last updated: May 26 '11

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More