|
|
I am a new man into java from c#. So sth still not familiar.
I downloaded POI and add JAR into my project. When I write some code for HSSFRow, I found there is no function for calculate row or column count.
Is there any way to do that?
Thanks in advance.
|
|
|
|
|
I think the number of rows and columns in a MS Excel table is not limited by default. Therefor you would not be able to get a row count.
regards
Torsten
I never finish anyth...
|
|
|
|
|
if it is .CSV file you can count,
else you cannot count the XLS rows and columns
***** Programme comme si dept soutien technique. est plein de tueurs en série et ils savent adresse de votre domicile. *****
|
|
|
|
|
hi how are you today
<b>(SORRY FOR MY BAD ENGLISH)</b>
i have a java program , i need this program to send me every 10 seconds "hi" message
but i need the program to keep running and every 10 seconds send me "hi"message
how can i do it ?
ty
|
|
|
|
|
The usual method is to use a timer[^] of some type. You may even find a sample here[^].
The best things in life are not things.
|
|
|
|
|
Hai Williamroma you can use Thread Class to run your program continuously and
use Thread.sleep(1000); method to wait for every 10 seconds. Within the if statement
it exceeds 10 seconds you can display the "hi" message from your program
|
|
|
|
|
Just a small correction, the parameter of Thread.sleep is in milliseconds, so 1000 is 1 second while 10000 is 10 seconds
it should be Thread.sleep(10000)
|
|
|
|
|
import java.util.Timer;
public class TimerExample {
public static void main(String[] args) {
Timer timer = new Timer();
long delay = 10000;
timer.schedule(new Task("object"), 0, delay);
}
}
***** Programme comme si dept soutien technique. est plein de tueurs en série et ils savent adresse de votre domicile. *****
|
|
|
|
|
1. A PROGRAM THAT PROVIDES THE INTERSECTION COORDINATES OF TWO LINES GIVEN THE COORDINATES OF LINE A AND LINE B.
2. A PROGRAM THAT WILL BE ABLE TO CALCULATE THE GRADIENT/SLOPE OF A LINE GIVEN TWO POINTS.
i want to know what i am doing to do, how to even start it i have no ideas can u pls explain to me how to go about it
NB:
i learn best by doing so i will be glad if u can add example codes to it
|
|
|
|
|
Start here[^]; it will teach you all the basics, and some of the advanced, aspects of Java programming.
The best things in life are not things.
|
|
|
|
|
0. If you study Sums 101, you'll know all lists start at item 0.
1. On the intar-web, all capitals LIKE THIS is considered shouting, don't do it.
2. In general good grammar is rewarded, and lack of proper punctuation or capitals allows us to feed you to our pet Dalek.
3. If you do the maths on paper, the code should be easy.
4. Don't drink whiskey before you've had breakfast.
Panic, Chaos, Destruction.
My work here is done.
or "Drink. Get drunk. Fall over." - P O'H
OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre
Have a bit more patience with newbies. Of course some of them act dumb -- they're often *students*, for heaven's sake. -- (Terry Pratchett, alt.fan.pratchett)
|
|
|
|
|
Are you learning math, programming or both?
And towards that do you understand the following math?
1. How to describe a line in a coordinate system?
2. How to find the intersection (or not) of two such lines.
|
|
|
|
|
7 close hi how are you today
<b>(SORRY FOR MY BAD ENGLISH)</b>
i want to sent data from Server to J2ME (using Java)
but i don't know when the server will send the data to my midlet
so how can i built a listener in midlet that listen to the resposne from server by (sure that response will receive using HTPPCOnnection)
plz help me , i need the solution
and tyvm.
|
|
|
|
|
IP traffic is based on two ends of the communication chain.
TCP is built on IP.
TCP has a 'client' and a 'server'. The client connects to the server (this has nothing to do with what the applications that contain the functionality are named.)
HTTP is built on TCP.
So in answer to your question.
1. You must have a 'server' that handled HTTP.
2. You then create a 'client' which sends HTTP requests to the 'server'.
You can't do anything unless you have both parts.
The server cannot be transitory. It must basically be up all the time. In other words it cannot come into existence only once a client sends a request.
|
|
|
|
|
ty
but..
how can i take the ip of an mobile
and what is the ip of the local host
and if you have any code example to deal with it
tyvm
|
|
|
|
|
williamroma wrote: how can i take the ip of an mobile
Why?
If you want the mobile to act as a client (and you can use sockets) then your question is meaningless.
If you want the mobile to act as a server then you must have an IP that is visible to the client. This however in general isn't what mobiles do but if it has the IP and sockets (which it would if it has an IP) then it is possible. Whether it is visible is a different issue.
Other than that you are asking a question about a specific mobile device because they are all different. It is pointless to ask how to do something on a mobile if it does not in fact have the minimum capability to support the solution. And whether it has Ip is not something that you determine with Java. Instead you look at the specification of the mobile itself.
|
|
|
|
|
ty 4 ur help
mabye i understand u
but i wana tell u all the problem
i want to make a chat program on Moblie
the program using emails on Hotmail
the chat include sending and receving IM
i can send the IM to my server then the server send it to the person (that i make chat with)
but with the person sends me a IM i can catch it in the server but how can i send it to the mobile
here is the problem cos i use HttpConnection
look:
the function
protected void doGet(HttpServletRequest request, HttpServletResponse response)
be in the server
i can send the IM from J2ME client to server and catch it in the request but when someone send the IM to the server how can i send it back to my J2ME client.
i know what i hv to use response but this object don't wait for the user to send data .. other words i dont know when the send the data to the server and so i do not know when i hv to send it to the client
plz help me , i have to make it , plz plz plz help me
tyvm
|
|
|
|
|
williamroma wrote: i have to make it
Why?
williamroma wrote: but i wana tell u all the problem
And I already told you the most significant part of the problem. You must determine what the mobile can do.
That isn't a java question. It isn't a question you can answer about a "mobile". You need to ask it about a specific (vendor) mobile.
williamroma wrote: the program using emails on Hotmail
That at least makes it likely that it can act as a client.
williamroma wrote: plz help me
I suggest you write the code, client and server on a desktop first.
|
|
|
|
|
the code in Client j2me
i beggin received when i pressed
receivedChat
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package myPage;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import javax.microedition.io.Connector;
import javax.microedition.io.HttpConnection;
import javax.microedition.lcdui.Choice;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.List;
import javax.microedition.lcdui.StringItem;
import javax.microedition.lcdui.TextField;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
/**
*
* @author William
*/
public class Main extends MIDlet implements CommandListener {
//HTTPCONNECTION
// HttpConnection hc = null;
OutputStream out = null;
InputStream in = null;
String URL = "http://localhost:8080/DeleteWebApplication/RomaServlet";
//GUI IN J2ME
Display display = null;
Form mainScreem = null;
TextField emailTextfield = null;
TextField passwordTextfield = null;
Form contactScreem = null;
Command loginCommand = null;
Command getContactsCommand = null;
//ACCONT IN MSN
String sessionId;
//GUI FOR ERROR CONNECTION
Form errorScreem = null;
StringItem errorMessege = null;
Command back = null;
//MY ACCOUNT IN MSN
int numberOfContacts;
//GUI FOR CONTACTS FRIENDLYNAMES
Form ContactsList = null;
StringItem[] contactsListGui = null;
//GUI FOR CHAT WITH ONE CONTACTS
Form chatScreem = null;
Command backToContactsList = null;
Command sendIMToContact = null;
public Main() {
display = Display.getDisplay(this);
mainScreem = new Form("Welcome...");
emailTextfield = new TextField("Email", "", 100, TextField.ANY);
passwordTextfield = new TextField("Password", "", 100, TextField.PASSWORD);
contactScreem = new Form("Your Contacts are:");
loginCommand = new Command("login", Command.BACK, 1);
getContactsCommand = new Command("get commands", Command.OK, 2);
mainScreem.append(emailTextfield);
mainScreem.append(passwordTextfield);
mainScreem.addCommand(loginCommand);
mainScreem.addCommand(getContactsCommand);
errorScreem = new Form("ERROR");
errorMessege = new StringItem("", "Cann't Connection to " + URL);
back = new Command("back", Command.BACK, 1);
errorMessege.addCommand(back);
errorScreem.append(errorMessege);
errorScreem.setCommandListener(this);
mainScreem.setCommandListener(this);
display.setCurrent(mainScreem);
}
protected void destroyApp(boolean unconditional) throws MIDletStateChangeException {
}
protected void pauseApp() {
}
protected void startApp() throws MIDletStateChangeException {
}
public void commandAction(Command c, Displayable d) {
if (c == loginCommand) {
String email = emailTextfield.getString();
String password = passwordTextfield.getString();
try {
HttpConnection hc = (HttpConnection) Connector.open(URL);
if (sessionId != null) {
hc.setRequestProperty("cookie", sessionId);
}
emailTextfield.setString("totti_william88@hotmail.com");
passwordTextfield.setString("williamroma");
hc.setRequestProperty("type", 1 + "");
byte len = (byte) email.length();
out = hc.openOutputStream();
out.write(len);
byte[] emailBytes = email.getBytes();
byte[] passwordBytes = password.getBytes();
for (int i = 0; i < emailBytes.length; i++) {
out.write(emailBytes[i]);
}
for (int i = 0; i < passwordBytes.length; i++) {
out.write(passwordBytes[i]);
}
out.flush();
out.close();
in = hc.openInputStream();
String cookie = hc.getHeaderField("Set-cookie");
if (cookie != null) {
int semicoln = cookie.indexOf(";");
sessionId = cookie.substring(0, semicoln);
}
StringBuffer sb = new StringBuffer();
int cha;
while ((cha = in.read()) != -1) {
sb.append((char) cha);
}
in.close();
hc.close();
System.out.println(sb.toString());
} catch (IOException ex) {
display.setCurrent(errorScreem);
}
}
if (c == back && d == errorScreem) {
display.setCurrent(mainScreem);
}
if (c == getContactsCommand) {
try {
HttpConnection hc = (HttpConnection) Connector.open(URL);
hc.setRequestProperty("type", 2 + "");
if (sessionId != null) {
hc.setRequestProperty("cookie", sessionId);
}
in = hc.openInputStream();
int ch;
String data = "";
/*while((ch=in.read())!=-1){
data+=(char)ch;
}
System.out.println("Data received :"+data);*/
data += (char) in.read();
numberOfContacts = Integer.parseInt(data);
System.out.println("The Number Of Contacts You Have are :" + numberOfContacts);
List list = new List("Contacts...", Choice.IMPLICIT);
contactsListGui = new StringItem[numberOfContacts];
ContactsList = new Form("Contacts...");
for (int i = 0; i < numberOfContacts; i++) {
data = "";
char stop = 0;
ch = in.read();
stop = (char) ch;
while (stop != '_') {
data += (char) ch;
ch = in.read();
stop = (char) ch;
}
int LenOfContactFrindlyName = Integer.parseInt(data);
System.out.println(LenOfContactFrindlyName);
data = "";
for (int j = 0; j < LenOfContactFrindlyName; j++) {
ch = in.read();
data += (char) ch;
}
System.out.println(data);
contactsListGui[i] = new StringItem("", data);
list.append(data, null);
ContactsList.append(contactsListGui[i]);
}
//display.setCurrent(ContactsList);
list.setCommandListener(this);
list.addCommand(help);
display.setCurrent(list);
} catch (IOException ex) {
ex.printStackTrace();
}
}
if (c == help) {
chatScreem = new Form("WilliamRoma");
chatScreem.append(textToSend);
chatScreem.setCommandListener(this);
sendIMToContact = new Command("send", Command.BACK, 1);
chatScreem.addCommand(sendIMToContact);
chatScreem.addCommand(receivedChat);
display.setCurrent(chatScreem);
}
if (c == sendIMToContact) {
String dataToSend = textToSend.getString();
textToSend.setString("");
try {
HttpConnection hc = (HttpConnection) Connector.open(URL);
hc.setRequestProperty("type", 3 + "");
if (sessionId != null) {
hc.setRequestProperty("cookie", sessionId);
}
out = hc.openOutputStream();
byte b[] = dataToSend.getBytes();
for (int i = 0; i < b.length; i++) {
out.write(b[i]);
}
out.flush();
out.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
if (c == receivedChat) {
try {
HttpConnection hc = (HttpConnection) Connector.open(URL);
hc.setRequestProperty("type", 4 + "");
if (sessionId != null) {
hc.setRequestProperty("cookie", sessionId);
}
in = hc.openInputStream();
int ch;
String data = "";
while ((ch = in.read()) != -1) {
data += (char) ch;
}
textToSend.setString(data);
/*in = hc.openInputStream();
int ch;
String data = "";
while ((ch = in.read()) != -1) {
data += (char) ch;
}
textToSend.setString(data);*/
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
Command help = new Command("help", Command.BACK, 1);
TextField textToSend = new TextField("", "chat", 100, TextField.ANY);
Command receivedChat = new Command("receive", Command.CANCEL, 2);
}
|
|
|
|
|
this is the serverlet in the server
public class RomaServlet extends HttpServlet {
public void processRequest(HttpServletRequest request, HttpServletResponse response) throws IOException {
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
@Override
public String getServletInfo() {
return "Short description";
}
MsnMessenger messenger = null;
BasicMessenger m = null;
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String type = request.getHeader("type");
System.out.println("my Type is :" + type);
if (type.equals("1")) {
HttpSession session = request.getSession(false);
int hits = 0;
BufferedReader br = request.getReader();
int len = br.read();//the length of Email ...
String email = "";
for (int i = 0; i < len; i++) {
email += (char) br.read();
}
String password = "";
int ch;
while ((ch = br.read()) != -1) {
password += (char) ch;
}
if (session == null) {
session = request.getSession(true);
session.setAttribute("Count", hits);
m = new BasicMessenger();
session.setAttribute("messenger", m);
Listener l = new Listener(session);
session.setAttribute("rere", "");
try {
m.start(messenger, email, password);
} catch (InstantiationException ex) {
Logger.getLogger(RomaServlet.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
Logger.getLogger(RomaServlet.class.getName()).log(Level.SEVERE, null, ex);
} catch (ClassNotFoundException ex) {
Logger.getLogger(RomaServlet.class.getName()).log(Level.SEVERE, null, ex);
}
}
session.setAttribute("Count", 1 + (Integer) session.getAttribute("Count"));
response.setContentType("text/plain");
PrintWriter out = response.getWriter();
out.println("Complete Login");
} else //if(type.equals("2"))
{
/* System.out.println("f*** GOD D D D D D ");
HttpSession session = request.getSession(false);
BasicMessenger mm;
mm = (BasicMessenger) session.getAttribute("messenger");
//HelloMessenger h = new HelloMessenger(mm.mymessenger);
mm.sendd("ya nealay");
mm.mymessenger.sendText(mm.mymessenger.getContactList().getContacts()[1].getEmail(), "hi williamroma");
PrintWriter out=response.getWriter();
out.println(mm.mymessenger.getOwner().getEmail().toString());
out.println(mm.mymessenger.getContactList().getContacts().length);
for(int i=0;i<mm.mymessenger.getContactList().getContacts().length;i++)
out.println(mm.mymessenger.getContactList().getContacts()[i].getEmail().toString());
* */
if (type.equals("2")) {
HttpSession session = request.getSession(false);
m = (BasicMessenger) session.getAttribute("messenger");
PrintWriter out = response.getWriter();
out.print(m.mymessenger.getContactList().getContacts().length);
for (int i = 0; i < m.mymessenger.getContactList().getContacts().length; i++) {
out.print(m.mymessenger.getContactList().getContacts()[i].getFriendlyName().length());
out.print('_');
out.print(m.mymessenger.getContactList().getContacts()[i].getFriendlyName());
}
}
if (type.equals("3")) {
HttpSession session = request.getSession(false);
m = (BasicMessenger) session.getAttribute("messenger");
BufferedReader br = request.getReader();
String dataReceived = "";
int ch;
while ((ch = br.read()) != -1) {
dataReceived += (char) ch;
}
m.mymessenger.sendText(m.mymessenger.getContactList().getContacts()[1].getEmail(), dataReceived);
}
if (type.equals("4")) {
HttpSession session = request.getSession(false);
m = (BasicMessenger) session.getAttribute("messenger");
TottiLisner t = new TottiLisner();
t.out=response.getWriter();
m.mymessenger.addListener(t);
while (t.rrr != true) {
}
t.rrr = false;
PrintWriter out = response.getWriter();
out.println(t.mmm);
}
}
}
}
|
|
|
|
|
this is the listener in the server
when i receive the IM
it is automaticllaly called the function
instantMessageReceived
<b>(SORRY FOR MY BAD ENGLISH)
(THANK YOU VERY MUCH)</b>
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package example;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.http.HttpServletResponse;
import net.sf.jml.MsnContact;
import net.sf.jml.MsnMessenger;
import net.sf.jml.MsnSwitchboard;
import net.sf.jml.event.MsnAdapter;
import net.sf.jml.message.MsnDatacastMessage;
import net.sf.jml.message.MsnInstantMessage;
/**
*
* @author William
*/
public class TottiLisner extends MsnAdapter{
public boolean rrr=false;
public MsnInstantMessage mmm;
public PrintWriter out;
public void exceptionCaught(MsnMessenger messenger, Throwable throwable) {
for(int i=0;i<10;i++)
System.out.println("TOTTI TOTTI TOTTI TOTTI TOTTI TOTTI");
}
public void instantMessageReceived(MsnSwitchboard switchboard,
MsnInstantMessage message,
MsnContact friend) {
rrr=true;
this.mmm=message;
}
public void datacastMessageReceived(MsnSwitchboard switchboard,
MsnDatacastMessage message,
MsnContact friend) {
for(int i=0;i<10;i++)
System.out.println("BUFFON BUFFON BUFFON BUFFON BUFFON");
}
}
|
|
|
|
|
but i dont't want to use socket
tyvm
|
|
|
|
|
williamroma wrote: but i dont't want to use socket
Huh?
HTTP is protocol based on TCP, thus sockets.
Thus your statement in the context of your question is nonsensical.
|
|
|
|
|
Sir ,
Can any one help me in reading the exact word content.
I have the following code with me:
_____***********Code start here*********----------------
import java.io.File;
import java.io.FileInputStream;
import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.extractor.WordExtractor;
public class DocRead1 {
public void readDocFile() {
File docFile = null;
WordExtractor docExtractor = null ;
WordExtractor exprExtractor = null ;
try {
docFile = new File("/Users/priyaranjan/Desktop/Hello.doc");
//A FileInputStream obtains input bytes from a file.
FileInputStream fis=new FileInputStream(docFile.getAbsolutePath());
//A HWPFDocument used to read document file from FileInputStream
HWPFDocument doc=new HWPFDocument(fis);
docExtractor = new WordExtractor(doc);
}
catch(Exception exep)
{
System.out.println(exep.getMessage());
}
//This Array stores each line from the document file.
String [] docArray = docExtractor.getParagraphText();
for(int i=0;i<docArray.length;i++)
{
if(docArray[i] != null)
System.out.println("Line "+ i +" : " + docArray[i]);
}
}
public static void main(String[] args) {
DocRead1 reader = new DocRead1();
reader.readDocFile();
}
}
------------*******Code ends here*********________________________
But i am getting the same out put whenever i made a change in font of letters used in word.I mean suppose in first case i have made the letter bold then in the second case i have made the letters italics.
But the above program is giving me the same output in both the case.I want to read the exact content of word document.
Can any one help me in this case...
Regards,
Priya
|
|
|
|