|
Hi guys , I do need help , cause i'm no a develloper but i have to do program on java that will read .txt file from database and get a specific String(FERME):
10/04/13 06:46 PS : 16 PN 239-Km 359.4 L.V K.ANI PN239 L/V: FERME
10/04/13 06:46 PS : 16 PN 239-Km 359.4 L.V 8V CdV C.J : 08.8 V
the file is made of multiple line like above, i just need to check if the file hade the word FERME....
thank you for your help
|
|
|
|
|
If that is all you need to do then it would be faster just to run the FIND command. However if there is more to it than that, and you are sure that you need a Java program, then you need to learn The Java Language[^] and the Basic I/O classes[^].
|
|
|
|
|
Sure I'm doing it but still :
-04-10-11:22:30. DEFAUT Z: .
RANDAN..
P0:.......
P1:.......
P2:.......
P3:.STA... 10/04 11:22
-04-10-11:22:55.............
RANDAN..
P0:.......
P1:.......
P2:.......
P3:.END DF 10/04 11:22
My files lines are structured like above,where the P1,P2..can change their states,at the specifique time,just want read those line and compare if the P1,P
,P3 states changed...please really nee ur help guys!!!...
|
|
|
|
|
mtouxx wrote: nee ur help guys With what? You still have not explained anything about your code or where it is having a problem/ What do you mean by P1,P2..can change their states,at the specifique time, or just want read those line and compare if the P1,P
,P3 states changed?
|
|
|
|
|
Ok i need a java code that helps me to read and check my file line by line, and in thoses line we get parameters, such as P1, P2,and P3, this file in to take on a data base, and each file get several lines
|
|
|
|
|
mtouxx wrote: i need a java code Well I'm afraid you are going to have to write it, as only you know what you are trying to do with the content of these files. The Scanner class[^] is probably a good one to help you parse the data.
|
|
|
|
|
Really appreciate thsi conversation such a helpfull!!!!..
|
|
|
|
|
But I think i better ask somewhere else!...
|
|
|
|
|
I think you may find the answers the same; no one is going to write this for you.
|
|
|
|
|
Someone kind enough I believe will help me..anyway think u for your attention!..
|
|
|
|
|
hello,
can any1 tell me how to develop a port scanner in java.I am not asking d entire code but atleast can any1 gimme an idea where 2 start from.
|
|
|
|
|
|
hello,
can any1 tell me how to develop a port scanner in java.
|
|
|
|
|
Google[^]
We can't do a lot for you if you don't give more details...
I will never again mention that Dalek Dave was the poster of the One Millionth Lounge Post, nor that it was complete drivel.
How to ask a question
|
|
|
|
|
I want to create a jquery dialog box which onlick of a image it has to load the dynamic page data and display. currently iam writing the code as below but its
not working.
var history = function(value, rowIndex) {
var id = this.grid.getItem(rowIndex).ID;
return "<img src=/img/showimg.jpg width=20 height=20 id=button1">";
};
<script>
$(function() {
$( "#dialog" ).dialog({
autoOpen: false,
show: {
effect: "blind",
duration: 1000
},
hide: {
effect: "explode",
duration: 1000
}
});
$( "#button1" ).click(function() {
$( "#dialog" ).dialog( "open" );
});
});
|
|
|
|
|
|
If I know
String IP = "127.0.0.1";
int port = 2020;
how an I estbish connection fomone client to this one in java Socket Programming.
I hae tried
Socket s = SocketFactory.getDefault().createSocket("localhost", Integer.parseInt(port));// sf = new SocketFactory;
but it is throwing exception.
Please help
|
|
|
|
|
The address "127.0.0.1" is the loopback address of your own PC, so you will need another program running there that is listening on that port. See http://docs.oracle.com/javase/tutorial/networking/sockets/[^] for the correct way to do it.
In future please do not just say "it is throwing exception. Please help". Provide the exact code that is failing, and full details of the exception or other error message.
|
|
|
|
|
Hi
Here i am posting my code that i have written
package com.evora.practice.swing;
import java.awt.BorderLayout;
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.filechooser.FileNameExtensionFilter;
public class PhotoViewer {
public static void main(String args[]){
new Main();
}
}
class ImageDraw extends Canvas{
/**
*
*/
private static final long serialVersionUID = 1L;
BufferedImage img;
double radian=0.0;
Dimension ds;
int iw;
int ih;
int x;
int y;
int adjX;
int adjY;
int adjW;
int adjH;
int mX;
int mY;
int orWidth;
int orHeight;
boolean rotate;
HashMap<integer, string=""> imgFiles;
String filename;
int curImgIndex;
ImageDraw(){
ds=getToolkit().getScreenSize(); //get the screen size
mX=(int)ds.getWidth()/4; //half of the screen width
mY=(int)ds.getHeight()/4; //half of the screen height
filename=null; //initialize filename variable
rotate=false; //initialize rotate variable
//initialize variables used to increase or decrease photo size
adjX=0;
adjY=1;
adjW=1;
adjH=1;
}
public void paint(Graphics g){
if(filename!=null){
if(rotate) //show rotated photo
rotateImage(g);
else
showImage(g); //show normal and zoom photo
}
}
//The rotateImage rotates the photo in clockwise or counterclockwise
//direction based on the radian value
public void rotateImage(Graphics g){
Graphics2D g2d=(Graphics2D)g;
g2d.translate(mX,mY); //move the original coordinate to point(mX,mY)
g2d.rotate(radian); //rotate the photo
g2d.translate(-iw/2,-ih/2); //move the coordinate back to point (iw/2,ih/2)
g2d.drawImage(img,0,0,iw,ih,null);//show the rotate photo
g2d.dispose(); //clean the g2d object
rotate=false; //reset the rotate to false after the photo rotates
}
//Increase the radian value by Math.PI/2
//so the photo is rotated in clockwise direction
public void rotateClockwise(){
radian+=Math.PI/2;
}
//Decrease the radian value by Math.PI/2
//so the photo is rotated in countclockwise direction
public void rotateCounterClockwise(){
radian-=Math.PI/2;
}
//The showImage method has code to display the photo when it is in
//normal view or zoom view
public void showImage(Graphics g){
Graphics2D g2d=(Graphics2D)g;
g2d.translate(x,y);
g2d.drawImage(img,0,0,iw,ih,null);
g2d.dispose();
}
public void readImage(String filename){
try{
//read the photo file so it is ready to display
img=ImageIO.read(new File(filename));
//get the original width and height of the photo
orWidth=img.getWidth();
orHeight=img.getHeight();
//Make sure the photo is not too large to fit the screen
if(mX<orwidth 2)
="" orwidth="mX*2;
" if(my<orheight="" orheight="mY*2;
" setimagebounds();
=""
="" }catch(ioexception="" e){};
="" }
="" determine="" the="" appropriate="" photo="" size="" and="" location="" to="" place="" photo
="" public="" void="" setimagebounds(){
="" try{
="" x="mX-orWidth/2+adjX;
" y="mY-orHeight/2+adjY;
" size
="" iw="orWidth+adjW;
" ih="orHeight+adjH;
" }catch(nullpointerexception="" npe){system.exit(-1);}
="" zoom="" in
="" decrease="" x-axis="" y-axis="" values="" at="" same="" time
="" increase="" width="" height
="" zoomin(){
="" adjx-="10;
" adjy-="10;
" adjw+="20;
" adjh+="20;
" out
="" zoomout(){
="" if(iw="">40 && ih>40){
adjX+=10;
adjY+=10;
adjW-=20;
adjH-=20;
setImageBounds();
}
}
//The storeImages method is invoked when the user select the Open... sub-menu
//item from the program interface
//It displays a file chooser dialog for multiple files selection
//The selected photos file are stored in a HashMap object imgList for
//later show
public void storeImages(){
imgFiles=new HashMap<integer, string="">();
JFileChooser chooser = new JFileChooser("C:\\Users\\Public\\Pictures\\Sample Pictures\\");
FileNameExtensionFilter filter = new FileNameExtensionFilter("Images", "jpg", "gif","png","bmp");
chooser.setFileFilter(filter);
chooser.setMultiSelectionEnabled(true);
int returnVal = chooser.showOpenDialog(this);
if(returnVal == JFileChooser.APPROVE_OPTION) {
File[] Files=chooser.getCurrentDirectory().listFiles();
for( int i=0;i<files.length;i++){
="" imgfiles.put(i,files[i].tostring());
="" }
="" the="" movefirst="" method="" has="" code="" to="" move="" first="" photo="" in="" imglist
="" public="" void="" movefirst(){
="" if(!imgfiles.isempty()){
="" curimgindex="0;" filename="imgFiles.get(curImgIndex);
" readimage(filename);
="" repaint();
="" movelast="" last="" movelast(){
="" moveprevious="" back="" moveprevious(){
="" if(!imgfiles.isempty()="" &&="" curimgindex!="0){
" curimgindex--;="" movenext="" forward="" movenext(){
="" curimgindex<imgfiles.size()-1){
="" curimgindex++;="" }
="" getimgfiles="" allows="" access="" list="" of="" photos--imglist
="" hashmap<integer,string=""> getImgFiles(){
return imgFiles;
}
}
//The Main class represents the interface of the PhotoView program
//On the interface, you see a File menu that has two sub-menu items: Open..., and Exit
//When the photo is displayed, the program will display a panel that contains
//all buttons you need to rotate, zoom, move, and play the slideshow of the photos
class Main extends JFrame implements ActionListener{
/**
*
*/
private static final long serialVersionUID = 1L;
JButton btrotateClockwise;
JButton btrotateCounterClockwise;
JButton btZoomIn;
JButton btPrevious;
JButton btNext;
JButton btZoomOut;
JButton btSlideShow;
JPanel panel;
ImageDraw imgDraw;
boolean stop=true;
ImageSlide Slider;
Main(){
setTitle("Photo Viewer");
setDefaultCloseOperation(EXIT_ON_CLOSE);
setExtendedState(this.getExtendedState() | JFrame.MAXIMIZED_BOTH);
setBackground(Color.CYAN);
JMenuBar mainmenu=new JMenuBar();
JMenu menu=new JMenu("File");
JMenuItem mopen=new JMenuItem("Open...");
mopen.setMnemonic(KeyEvent.VK_O);
mopen.addActionListener(this);
JMenuItem mexit=new JMenuItem("Exit");
mexit.setMnemonic(KeyEvent.VK_X);
mexit.addActionListener(this);
menu.add(mopen);
menu.add(mexit);
mainmenu.add(menu);
setJMenuBar(mainmenu);
btrotateClockwise=new JButton("ROTATE RIGHT");
btrotateClockwise.setBackground(Color.GREEN);
btrotateClockwise.addActionListener(this);
btrotateCounterClockwise=new JButton("ROTATE LEFT");
btrotateCounterClockwise.setBackground(Color.YELLOW);
btrotateCounterClockwise.addActionListener(this);
btZoomIn=new JButton("ZOOMIN");
btZoomIn.setBackground(Color.MAGENTA);
btZoomIn.addActionListener(this);
btZoomOut=new JButton("ZOOMOUT");
btZoomOut.setBackground(Color.PINK);
btZoomOut.addActionListener(this);
btPrevious=new JButton("BACK");
btPrevious.setBackground(Color.ORANGE);
btPrevious.addActionListener(this);
btNext=new JButton("NEXT");
btNext.setBackground(Color.GRAY);
btNext.addActionListener(this);
btSlideShow=new JButton("PLAYALL");
btSlideShow.setBackground(Color.WHITE);
btSlideShow.addActionListener(this);
panel=new JPanel();
panel.setLayout(new FlowLayout());
panel.add(btrotateClockwise);
panel.add(btrotateCounterClockwise);
panel.add(btZoomIn);
panel.add(btZoomOut);
panel.add(btNext);
panel.add(btPrevious);
panel.add(btSlideShow);
panel.setBackground(Color.BLACK);
add(panel, BorderLayout.SOUTH);
imgDraw=new ImageDraw();
add(imgDraw,BorderLayout.CENTER );
setVisible(true);
panel.setVisible(false);
}
//*handling buttons and sub-menu items clicks
public void actionPerformed(ActionEvent e){
if(e.getSource()==btrotateClockwise)
{
imgDraw.rotate=true;
imgDraw.rotateClockwise();
imgDraw.repaint();
}
else if(e.getSource()==btrotateCounterClockwise)
{
imgDraw.rotate=true;
imgDraw.rotateCounterClockwise();
imgDraw.repaint();
}
else if(e.getSource()==btZoomIn)
{
imgDraw.zoomIn();
imgDraw.repaint();
}
else if(e.getSource()==btZoomOut)
{
imgDraw.zoomOut();
imgDraw.repaint();
}
else if(e.getSource()==btPrevious)
{
imgDraw.movePrevious();
}
else if(e.getSource()==btNext)
{
imgDraw.moveNext();
}
else if(e.getSource()==btSlideShow)
{
if(stop){
startClick();
}
else{
stopClick();
}
}
else{
JMenuItem source = (JMenuItem)(e.getSource());
if(source.getText().compareTo("Open...")==0)
{
imgDraw.storeImages();
imgDraw.moveFirst();
panel.setVisible(true);
}
else if(source.getText().compareTo("Exit")==0)
System.exit(0);
}
}
//The stopClick method invoked when you click the Pause button
//*to stop the slideshow
public void stopClick(){
btSlideShow.setIcon(new ImageIcon("playall.png"));
stop=true;
Slider.stopShow();
}
//The startClick method invoked when you click the Play button
//to start the slideshow
public void startClick(){
btSlideShow.setIcon(new ImageIcon("pause.png"));
stop=false;
Slider=new ImageSlide();
Slider.start();
}
//The ImageSlide class handle the photo slideshow process
//When you click the Play button the run method of this class is invoked
//When you click the Pause button the stopShow method of this class is invoked
class ImageSlide extends Thread{
boolean started;
HashMap<integer,string> map;
ImageSlide(){
started=true;
map=imgDraw.getImgFiles();
}
public void run(){
int i;
try{
for(i=0;i
|
|
|
|
|
- Please edit the above and use the code button to put <pre> tags around your code so it is readable.
- Show us the line in the code where the error occurs.
|
|
|
|
|
|
java.lang.ClassNotFoundException: Could not load requested class : com.mysql.jdbc.driver .
This is coming while executing..I have also updated the buildpath by hibernate jars & mysql connector bin jar.still it is not working
|
|
|
|
|
you can post your query on javatpoint forum.
www.javatpoint.com/forum
|
|
|
|
|
Have you written mysql dialect in hibernate.cfg.xml??
|
|
|
|
|
Hello My Fren,please help me
I have serious problem here
whts the code or how to connect to database for input/save data and to show the data pleaseee
Thanks
|
|
|
|