Hi frndz !!!!!! we are again here to share our practically done work in gwt i.e. we make a text file or we convert the richtexteditor matter into the text file as follows:-
This file is to make richtexteditor and in this file there is onclick event of a button which will asynchronously call the writee() method at server side
Note- Make a "image" folder in war folder of your project.In this folder the textfile and images for richtexteditor fuctionality pictures will save.
Write.java
package com.client;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Date;
import com.gargoylesoftware.htmlunit.javascript.host.Window;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RichTextArea;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.RichTextArea.ExtendedFormatter;
import com.gwtext.client.widgets.Toolbar;
import com.gwtext.client.widgets.ToolbarButton;
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.gwtext.client.core.EventObject;
import com.google.gwt.user.datepicker.client.DateBox;
import com.gwtext.client.widgets.form.TimeField;
import com.google.gwt.user.datepicker.client.DateBox.DefaultFormat;
import com.google.gwt.i18n.client.DateTimeFormat;
@SuppressWarnings("deprecation")
public class Write extends Composite {
RootPanel rootpanel;
AbsolutePanel absolutePanel;
Label stream;
ListBox streamvalue ;
Label subject;
ListBox subjectvalue;
Label lblTypeAProblem;
RichTextArea richTextArea;
ExtendedFormatter formatter;
Toolbar tt;
ToolbarButton bold;
ToolbarButton italic;
ToolbarButton underline;
ToolbarButton leftjustification;
ToolbarButton rightjustification;
ToolbarButton centerjustification;
ListBox fontsize;
public Write() {
final GreetingServiceAsync a1= GWT.create(GreetingService.class);
rootpanel=RootPanel.get();
absolutePanel = new AbsolutePanel();
rootpanel.add(absolutePanel, 191, -4);
absolutePanel.setSize("450px", "382px");
stream = new Label("Stream");
absolutePanel.add(stream, 201, 22);
richTextArea = new RichTextArea();
absolutePanel.add(richTextArea, 86, 170);
richTextArea.setSize("354px", "98px");
formatter=richTextArea.getExtendedFormatter();
tt=new Toolbar();
absolutePanel.add(tt, 88, 130);
tt.setSize("351px", "31px");
fontsize = new ListBox();
absolutePanel.add(fontsize, 244, 134);
fontsize.setSize("35px", "27px");
fontsize.addItem("1");
fontsize.addItem("2");
fontsize.addItem("3");
fontsize.addItem("4");
fontsize.addItem("5");
fontsize.addItem("6");
fontsize.addItem("7");
// tglbtnB = new ToggleButton("B");
bold=new ToolbarButton();
//bold.setToggleGroup("");
bold.setText("");
bold.setTooltip("Bold");
bold.setCls("button");
bold.setToggleGroup("format");
bold.setIconCls("G:/gwt-2.0.4/gwt-2.0.4/proj/war/images/bold.gif");
tt.addButton(bold);
bold.setSize("34px", "30px");
italic=new ToolbarButton();
italic.setText("");
italic.setTooltip("Italic");
italic.setToggleGroup("format");
italic.setIcon("G:/gwt-2.0.4/gwt-2.0.4/proj/war/images/italic.gif");
tt.addButton(italic);
underline=new ToolbarButton();
underline.setText("");
underline.setToggleGroup("format");
underline.setIcon("G:/gwt-2.0.4/gwt-2.0.4/proj/war/images/underline.gif");
tt.addButton(underline);
leftjustification=new ToolbarButton();
leftjustification.setToggleGroup("justification");
leftjustification.setTooltip("left");
leftjustification.setText("");
leftjustification.setIcon("G:/gwt-2.0.4/gwt-2.0.4/proj/war/images/justifyleft.gif");
tt.addButton(leftjustification);
centerjustification=new ToolbarButton();
centerjustification.setToggleGroup("justification");
centerjustification.setText("");
centerjustification.setIcon("G:/gwt-2.0.4/gwt-2.0.4/proj/war/images/justifyCenter.gif");
centerjustification.setTooltip("Center");
tt.addButton(centerjustification);
rightjustification=new ToolbarButton();
rightjustification.setToggleGroup("justification");
rightjustification.setText("");
rightjustification.setIcon("G:/gwt-2.0.4/gwt-2.0.4/proj/war/images/justifyRight.gif");
rightjustification.setTooltip("Right");
tt.addButton(rightjustification);
DateBox dateBox = new DateBox();
dateBox.setFormat(new DefaultFormat(DateTimeFormat.getFullDateFormat()));
absolutePanel.add(dateBox, 177, 549);
dateBox.setSize("98px", "23px");
Label lblEnterDatetime = new Label("Enter Date/Time");
absolutePanel.add(lblEnterDatetime, 56, 549);
TimeField timeField = new TimeField("New time field", "time_field", 100);
absolutePanel.add(timeField, 298, 548);
Label lblTitle = new Label("Title");
absolutePanel.add(lblTitle, 119, 52);
lblTitle.setSize("254px", "18px");
final TextBox txtbxTitle = new TextBox();
txtbxTitle.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
txtbxTitle.setText("");
}
});
txtbxTitle.setText("Title");
absolutePanel.add(txtbxTitle, 257, 46);
txtbxTitle.setSize("166px", "16px");
Label lblAuthor = new Label("Author");
absolutePanel.add(lblAuthor, 124, 82);
lblAuthor.setSize("257px", "18px");
final TextBox txtbxAuthorName = new TextBox();
txtbxAuthorName.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
txtbxAuthorName.setText("");
}
});
txtbxAuthorName.setText("Author name");
absolutePanel.add(txtbxAuthorName, 260, 80);
txtbxAuthorName.setSize("163px", "16px");
Button button_1 = new Button("New button");
button_1.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
String ss=richTextArea.getText();
String st=txtbxTitle.getText();
String sa=txtbxAuthorName.getText();
a1.writee(ss, sa,st, new AsyncCallback<String>() {
@Override
public void onSuccess(String result) {
// TODO Auto-generated method stub
System.out.println("i am just me jhiojjkj");
System.out.println("i am just me");
}
@Override
public void onFailure(Throwable caught) {
// TODO Auto-generated method stub
}
});
}
});
button_1.setText("Submit");
absolutePanel.add(button_1, 213, 274);
button_1.setSize("100px", "28px");
bold.addListener(new ButtonListenerAdapter() {
public void onClick(com.gwtext.client.widgets.Button button, EventObject e) {
//richTextArea.setHTML("<b></b>");
formatter.toggleBold();
}
});
italic.addListener(new ButtonListenerAdapter() {
public void onClick(com.gwtext.client.widgets.Button button, EventObject e) {
formatter.toggleItalic();
}
});
underline.addListener(new ButtonListenerAdapter() {
public void onClick(com.gwtext.client.widgets.Button button, EventObject e) {
formatter.toggleUnderline();
}
});
leftjustification.addListener(new ButtonListenerAdapter() {
public void onClick(com.gwtext.client.widgets.Button button, EventObject e) {
formatter.setJustification(RichTextArea.Justification.LEFT);
}
});
centerjustification.addListener(new ButtonListenerAdapter() {
public void onClick(com.gwtext.client.widgets.Button button, EventObject e) {
formatter.setJustification(RichTextArea.Justification.CENTER);
}
});
rightjustification.addListener(new ButtonListenerAdapter() {
public void onClick(com.gwtext.client.widgets.Button button, EventObject e) {
formatter.setJustification(RichTextArea.Justification.RIGHT);
}
});
fontsize.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
if(fontsize.isItemSelected(0))
formatter.setFontSize(RichTextArea.FontSize.XX_SMALL);
if(fontsize.isItemSelected(1))
formatter.setFontSize(RichTextArea.FontSize.X_SMALL);
if(fontsize.isItemSelected(2))
formatter.setFontSize(RichTextArea.FontSize.SMALL);
if(fontsize.isItemSelected(3))
formatter.setFontSize(RichTextArea.FontSize.MEDIUM);
if(fontsize.isItemSelected(4))
formatter.setFontSize(RichTextArea.FontSize.LARGE);
if(fontsize.isItemSelected(5))
formatter.setFontSize(RichTextArea.FontSize.X_LARGE);
if(fontsize.isItemSelected(6))
formatter.setFontSize(RichTextArea.FontSize.XX_LARGE);
}
});
}
}
GreetingService.java
package com.client;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
/**
* The client side stub for the RPC service.
*/
@RemoteServiceRelativePath("greet")
public interface GreetingService extends RemoteService {
String check(String name, String password);
String sign(String name, String password);
String writee(String ss,String st,String sa);
}
import com.google.gwt.user.client.rpc.AsyncCallback;
/**
* The async counterpart of <code>GreetingService</code>.
*/
public interface GreetingServiceAsync {
void check(String name, String password, AsyncCallback<String> callback);
void sign(String name, String password, AsyncCallback<String> callback);
void writee(String ss, String sa,String st, AsyncCallback<String> callback);
}
GreetingServiceImpl.java
package com.server;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Date;
import com.client.GreetingService;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
/**
* The server side implementation of the RPC service.
*/
@SuppressWarnings("serial")
public class GreetingServiceImpl extends RemoteServiceServlet implements
GreetingService {
Connection con=null;
Statement st=null;
ResultSet rs=null;
String query;
String url="jdbc:mysql://localhost:3306/logindb";
public void call()
{
try
{
Class.forName("com.mysql.jdbc.Driver");
}
catch(ClassNotFoundException e)
{
System.out.print(e.getMessage());
}
try
{
con=DriverManager.getConnection(url, "root", "");
st=con.createStatement();
}
catch(SQLException e)
{
System.out.println(e.getMessage());
}
}
@Override
public String check(String name, String password) {
// TODO Auto-generated method stub
String ss="no";
call();
try
{
rs = st.executeQuery("select * from admin where name='" + name + "' and password='" + password+"'" );
if(rs.next())
{
ss="yes";
System.out.println(rs.getString("name"));
System.out.println(rs.getString("password"));
}
}
catch(SQLException e)
{
System.out.println(e.getMessage());
}
return ss;
}
@Override
public String sign(String name, String password) {
String ss="no";
int k=0;
call();
try
{
k=st.executeUpdate("insert into admin values('" + name + "','" + password+"')" );
if(k==1)
{
ss="yes";
}
}
catch(SQLException e)
{
System.out.println(e.getMessage());
}
return ss;
// TODO Auto-generated method stub
}
@SuppressWarnings("deprecation")
@Override
public String writee(String ss, String st, String sa) {
// TODO Auto-generated method stub
FileWriter ryt;
try{
System.out.println("123456789");
Date today = new Date();
// DateTimeFormat fmt = DateTimeFormat.getFormat("EEEE_MMMM_dd_yyyy");
// prints Monday, December 17, 2007 in the default locale
//GWT.log(fmt.format(today), null);
int s1=today.getDate();
int s2=today.getMonth();
int s3=today.getYear();
int s4=today.getHours();
int s5=today.getMinutes();
int s6=today.getSeconds();
File ff=new File("G://gwt-2.0.4//gwt-2.0.4//proj//war//images//"+st+sa+"_"+s1+"."+s2+"."+s3+"_"+s4+"."+s5+"."+s6+".txt");
ff.createNewFile();
ryt=new FileWriter("G://gwt-2.0.4//gwt-2.0.4//proj//war//images//"+st+sa+"_"+s1+"."+s2+"."+s3+"_"+s4+"."+s5+"."+s6+".txt");
BufferedWriter out = new BufferedWriter(ryt);
out.write(ss);
out.close();
System.out.println("12dssdsfdbvfd3456789");
}
catch(Exception e)
{
System.out.println(e+"bghh");
}
return ss;
}
Now You can use this code to make text file in gwt.
For any other discussion about this topic are most welcome ...
This file is to make richtexteditor and in this file there is onclick event of a button which will asynchronously call the writee() method at server side
Note- Make a "image" folder in war folder of your project.In this folder the textfile and images for richtexteditor fuctionality pictures will save.
Write.java
package com.client;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Date;
import com.gargoylesoftware.htmlunit.javascript.host.Window;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RichTextArea;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.RichTextArea.ExtendedFormatter;
import com.gwtext.client.widgets.Toolbar;
import com.gwtext.client.widgets.ToolbarButton;
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.gwtext.client.core.EventObject;
import com.google.gwt.user.datepicker.client.DateBox;
import com.gwtext.client.widgets.form.TimeField;
import com.google.gwt.user.datepicker.client.DateBox.DefaultFormat;
import com.google.gwt.i18n.client.DateTimeFormat;
@SuppressWarnings("deprecation")
public class Write extends Composite {
RootPanel rootpanel;
AbsolutePanel absolutePanel;
Label stream;
ListBox streamvalue ;
Label subject;
ListBox subjectvalue;
Label lblTypeAProblem;
RichTextArea richTextArea;
ExtendedFormatter formatter;
Toolbar tt;
ToolbarButton bold;
ToolbarButton italic;
ToolbarButton underline;
ToolbarButton leftjustification;
ToolbarButton rightjustification;
ToolbarButton centerjustification;
ListBox fontsize;
public Write() {
final GreetingServiceAsync a1= GWT.create(GreetingService.class);
rootpanel=RootPanel.get();
absolutePanel = new AbsolutePanel();
rootpanel.add(absolutePanel, 191, -4);
absolutePanel.setSize("450px", "382px");
stream = new Label("Stream");
absolutePanel.add(stream, 201, 22);
richTextArea = new RichTextArea();
absolutePanel.add(richTextArea, 86, 170);
richTextArea.setSize("354px", "98px");
formatter=richTextArea.getExtendedFormatter();
tt=new Toolbar();
absolutePanel.add(tt, 88, 130);
tt.setSize("351px", "31px");
fontsize = new ListBox();
absolutePanel.add(fontsize, 244, 134);
fontsize.setSize("35px", "27px");
fontsize.addItem("1");
fontsize.addItem("2");
fontsize.addItem("3");
fontsize.addItem("4");
fontsize.addItem("5");
fontsize.addItem("6");
fontsize.addItem("7");
// tglbtnB = new ToggleButton("B");
bold=new ToolbarButton();
//bold.setToggleGroup("");
bold.setText("");
bold.setTooltip("Bold");
bold.setCls("button");
bold.setToggleGroup("format");
bold.setIconCls("G:/gwt-2.0.4/gwt-2.0.4/proj/war/images/bold.gif");
tt.addButton(bold);
bold.setSize("34px", "30px");
italic=new ToolbarButton();
italic.setText("");
italic.setTooltip("Italic");
italic.setToggleGroup("format");
italic.setIcon("G:/gwt-2.0.4/gwt-2.0.4/proj/war/images/italic.gif");
tt.addButton(italic);
underline=new ToolbarButton();
underline.setText("");
underline.setToggleGroup("format");
underline.setIcon("G:/gwt-2.0.4/gwt-2.0.4/proj/war/images/underline.gif");
tt.addButton(underline);
leftjustification=new ToolbarButton();
leftjustification.setToggleGroup("justification");
leftjustification.setTooltip("left");
leftjustification.setText("");
leftjustification.setIcon("G:/gwt-2.0.4/gwt-2.0.4/proj/war/images/justifyleft.gif");
tt.addButton(leftjustification);
centerjustification=new ToolbarButton();
centerjustification.setToggleGroup("justification");
centerjustification.setText("");
centerjustification.setIcon("G:/gwt-2.0.4/gwt-2.0.4/proj/war/images/justifyCenter.gif");
centerjustification.setTooltip("Center");
tt.addButton(centerjustification);
rightjustification=new ToolbarButton();
rightjustification.setToggleGroup("justification");
rightjustification.setText("");
rightjustification.setIcon("G:/gwt-2.0.4/gwt-2.0.4/proj/war/images/justifyRight.gif");
rightjustification.setTooltip("Right");
tt.addButton(rightjustification);
DateBox dateBox = new DateBox();
dateBox.setFormat(new DefaultFormat(DateTimeFormat.getFullDateFormat()));
absolutePanel.add(dateBox, 177, 549);
dateBox.setSize("98px", "23px");
Label lblEnterDatetime = new Label("Enter Date/Time");
absolutePanel.add(lblEnterDatetime, 56, 549);
TimeField timeField = new TimeField("New time field", "time_field", 100);
absolutePanel.add(timeField, 298, 548);
Label lblTitle = new Label("Title");
absolutePanel.add(lblTitle, 119, 52);
lblTitle.setSize("254px", "18px");
final TextBox txtbxTitle = new TextBox();
txtbxTitle.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
txtbxTitle.setText("");
}
});
txtbxTitle.setText("Title");
absolutePanel.add(txtbxTitle, 257, 46);
txtbxTitle.setSize("166px", "16px");
Label lblAuthor = new Label("Author");
absolutePanel.add(lblAuthor, 124, 82);
lblAuthor.setSize("257px", "18px");
final TextBox txtbxAuthorName = new TextBox();
txtbxAuthorName.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
txtbxAuthorName.setText("");
}
});
txtbxAuthorName.setText("Author name");
absolutePanel.add(txtbxAuthorName, 260, 80);
txtbxAuthorName.setSize("163px", "16px");
Button button_1 = new Button("New button");
button_1.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
String ss=richTextArea.getText();
String st=txtbxTitle.getText();
String sa=txtbxAuthorName.getText();
a1.writee(ss, sa,st, new AsyncCallback<String>() {
@Override
public void onSuccess(String result) {
// TODO Auto-generated method stub
System.out.println("i am just me jhiojjkj");
System.out.println("i am just me");
}
@Override
public void onFailure(Throwable caught) {
// TODO Auto-generated method stub
}
});
}
});
button_1.setText("Submit");
absolutePanel.add(button_1, 213, 274);
button_1.setSize("100px", "28px");
bold.addListener(new ButtonListenerAdapter() {
public void onClick(com.gwtext.client.widgets.Button button, EventObject e) {
//richTextArea.setHTML("<b></b>");
formatter.toggleBold();
}
});
italic.addListener(new ButtonListenerAdapter() {
public void onClick(com.gwtext.client.widgets.Button button, EventObject e) {
formatter.toggleItalic();
}
});
underline.addListener(new ButtonListenerAdapter() {
public void onClick(com.gwtext.client.widgets.Button button, EventObject e) {
formatter.toggleUnderline();
}
});
leftjustification.addListener(new ButtonListenerAdapter() {
public void onClick(com.gwtext.client.widgets.Button button, EventObject e) {
formatter.setJustification(RichTextArea.Justification.LEFT);
}
});
centerjustification.addListener(new ButtonListenerAdapter() {
public void onClick(com.gwtext.client.widgets.Button button, EventObject e) {
formatter.setJustification(RichTextArea.Justification.CENTER);
}
});
rightjustification.addListener(new ButtonListenerAdapter() {
public void onClick(com.gwtext.client.widgets.Button button, EventObject e) {
formatter.setJustification(RichTextArea.Justification.RIGHT);
}
});
fontsize.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
if(fontsize.isItemSelected(0))
formatter.setFontSize(RichTextArea.FontSize.XX_SMALL);
if(fontsize.isItemSelected(1))
formatter.setFontSize(RichTextArea.FontSize.X_SMALL);
if(fontsize.isItemSelected(2))
formatter.setFontSize(RichTextArea.FontSize.SMALL);
if(fontsize.isItemSelected(3))
formatter.setFontSize(RichTextArea.FontSize.MEDIUM);
if(fontsize.isItemSelected(4))
formatter.setFontSize(RichTextArea.FontSize.LARGE);
if(fontsize.isItemSelected(5))
formatter.setFontSize(RichTextArea.FontSize.X_LARGE);
if(fontsize.isItemSelected(6))
formatter.setFontSize(RichTextArea.FontSize.XX_LARGE);
}
});
}
}
GreetingService.java
package com.client;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
/**
* The client side stub for the RPC service.
*/
@RemoteServiceRelativePath("greet")
public interface GreetingService extends RemoteService {
String check(String name, String password);
String sign(String name, String password);
String writee(String ss,String st,String sa);
}
GreetingServiceAsync.java
package com.client;import com.google.gwt.user.client.rpc.AsyncCallback;
/**
* The async counterpart of <code>GreetingService</code>.
*/
public interface GreetingServiceAsync {
void check(String name, String password, AsyncCallback<String> callback);
void sign(String name, String password, AsyncCallback<String> callback);
void writee(String ss, String sa,String st, AsyncCallback<String> callback);
}
GreetingServiceImpl.java
package com.server;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Date;
import com.client.GreetingService;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
/**
* The server side implementation of the RPC service.
*/
@SuppressWarnings("serial")
public class GreetingServiceImpl extends RemoteServiceServlet implements
GreetingService {
Connection con=null;
Statement st=null;
ResultSet rs=null;
String query;
String url="jdbc:mysql://localhost:3306/logindb";
public void call()
{
try
{
Class.forName("com.mysql.jdbc.Driver");
}
catch(ClassNotFoundException e)
{
System.out.print(e.getMessage());
}
try
{
con=DriverManager.getConnection(url, "root", "");
st=con.createStatement();
}
catch(SQLException e)
{
System.out.println(e.getMessage());
}
}
@Override
public String check(String name, String password) {
// TODO Auto-generated method stub
String ss="no";
call();
try
{
rs = st.executeQuery("select * from admin where name='" + name + "' and password='" + password+"'" );
if(rs.next())
{
ss="yes";
System.out.println(rs.getString("name"));
System.out.println(rs.getString("password"));
}
}
catch(SQLException e)
{
System.out.println(e.getMessage());
}
return ss;
}
@Override
public String sign(String name, String password) {
String ss="no";
int k=0;
call();
try
{
k=st.executeUpdate("insert into admin values('" + name + "','" + password+"')" );
if(k==1)
{
ss="yes";
}
}
catch(SQLException e)
{
System.out.println(e.getMessage());
}
return ss;
// TODO Auto-generated method stub
}
@SuppressWarnings("deprecation")
@Override
public String writee(String ss, String st, String sa) {
// TODO Auto-generated method stub
FileWriter ryt;
try{
System.out.println("123456789");
Date today = new Date();
// DateTimeFormat fmt = DateTimeFormat.getFormat("EEEE_MMMM_dd_yyyy");
// prints Monday, December 17, 2007 in the default locale
//GWT.log(fmt.format(today), null);
int s1=today.getDate();
int s2=today.getMonth();
int s3=today.getYear();
int s4=today.getHours();
int s5=today.getMinutes();
int s6=today.getSeconds();
File ff=new File("G://gwt-2.0.4//gwt-2.0.4//proj//war//images//"+st+sa+"_"+s1+"."+s2+"."+s3+"_"+s4+"."+s5+"."+s6+".txt");
ff.createNewFile();
ryt=new FileWriter("G://gwt-2.0.4//gwt-2.0.4//proj//war//images//"+st+sa+"_"+s1+"."+s2+"."+s3+"_"+s4+"."+s5+"."+s6+".txt");
BufferedWriter out = new BufferedWriter(ryt);
out.write(ss);
out.close();
System.out.println("12dssdsfdbvfd3456789");
}
catch(Exception e)
{
System.out.println(e+"bghh");
}
return ss;
}
}
Now You can use this code to make text file in gwt.
For any other discussion about this topic are most welcome ...
0 Response to "Creating Text File from Richtexteditor in GWT"
Post a Comment