import com.sun.speech.freetts.Voice;
import com.sun.speech.freetts.VoiceManager;
import java.sql.*;
import java.io.*;
/**
*
* @author LoveBharti
*/
public class Misc
{
public static void convertTextToSound(String texttoConvert)
{
String voiceName = "kevin16";
VoiceManager voiceManager = VoiceManager.getInstance();
Voice helloVoice = voiceManager.getVoice(voiceName);
if (helloVoice == null)
{
System.err.println("Cannot find a voice named "+ voiceName + ". Please specify a different voice.");
return;
}
helloVoice.allocate();
helloVoice.speak(texttoConvert);
helloVoice.deallocate();
return;
}
public static void appOpener(String fileName)
{
try
{
Process p = Runtime.getRuntime().exec("Xpad/"+fileName+".exe");
} catch (Exception e) {e.printStackTrace();}
}
public static Connection connect(Connection con) throws ClassNotFoundException, SQLException
{
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/wordlist","root","");
return con;
}
public static void mergeTable(String db,String table1,String table2) throws ClassNotFoundException, SQLException
{
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/"+db,"root","");
Statement st=con.createStatement();
String sqlc="INSERT into "+table1+" (Select * from "+table2+")";
st.executeUpdate(sqlc);
}
public static void fileToDBFeeder() throws ClassNotFoundException, SQLException, FileNotFoundException, IOException
{
Connection con=Misc.connect(null);
Statement st=con.createStatement();
String tableName="name";
FileInputStream fis=new FileInputStream("file.txt"); //string -> BufferedReader -> InputStreamReader -> DataInputStream -> FileInputStream
DataInputStream dis = new DataInputStream(fis);
InputStreamReader isr = new InputStreamReader(dis);
BufferedReader br = new BufferedReader(isr);
String text;
while((text=br.readLine())!=null) //fulltext=fulltext+text;
{
if(!text.contains("'"))
{
String sqlc="insert into "+tableName+" values('"+text.toLowerCase()+"','job title')";
st.executeUpdate(sqlc);
}
System.out.println(text);
}
dis.close();
//return fulltext;
}
}
No comments:
Post a Comment