|
Since no one else replied.
1. I would parse the html and handle a LIMITED set of attributes.
2. I would limit the size and refuse to handle anything over a certain limit. I would log an error to indicate it
3. For unknown attributes I would strip them and log a warning.
4. I would document (not code) what was allowed for html in that data slot.
|
|
|
|
|
I want to find a way to convert Microsoft's word to PDF on linux. My idea is to read each word, picture, or table first, and then write their structure into the PDF document. But when I read the format of the document and write it to PDF, only the pictures can be written and the styles are completely different from those in the document. I would like to ask a kind person if you have any experience in this field. Please give me some advice or guidance. Thank you!
|
|
|
|
|
The issue is not too complicated. Firstly you need to understand the structure of Word documents, and how different parts are formatted, and which fonts are used to render the text. You then need to learn how to reformat that information into the structures that a PDF document uses. There are various libraries around to do both parts, and Google will find you the details.
|
|
|
|
|
ok,thank you man,i'll try it
|
|
|
|
|
For me what worked easiest on Linux:
- install OpenOffice or LibreOffice (whatever your Linux distro has as the default)
- then use the PDF converter tool that comes with LibreOffice (or Open...)
It is a simple command line tool that has tons of options. For Word it should provide really decent output as long as you have no real complex stuff in it.
|
|
|
|
|
write a program for a bank employee .
so that when he enters his/her ID the system can tell him to which bank he belongs and what is his designation.Is he a manager , normal employee, sales person, cashier .
manager can perform all the tasks but cashier ca deposit/withdraw cash, sales person can only upload documents etc.
|
|
|
|
|
|
We do not do your HomeWork.
HomeWork is not set to test your skills at begging other people to do your work, it is set to make you think and to help your teacher to check your understanding of the courses you have taken and also the problems you have at applying them.
Any failure of you will help your teacher spot your weaknesses and set remedial actions.
Any failure of you will help you to learn what works and what don't, it is called 'trial and error' learning.
So, give it a try, reread your lessons and start working. If you are stuck on a specific problem, show your code and explain this exact problem, we might help.
As programmer, your job is to create algorithms that solve specific problems and you can't rely on someone else to eternally do it for you, so there is a time where you will have to learn how to. And the sooner, the better.
When you just ask for the solution, it is like trying to learn to drive a car by having someone else training.
Creating an algorithm is basically finding the maths and make necessary adaptation to fit your actual problem.
The idea of "development" is as the word suggests: "The systematic use of scientific and technical knowledge to meet specific objectives or requirements." BusinessDictionary.com[^]
That's not the same thing as "have a quick google and give up if I can't find exactly the right code".
An interesting link to get you started on a new project: Systems development life cycle - Wikipedia[^]
Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein
|
|
|
|
|
how to connect ble sensor in swing-java using netsbeans
or
how to create window application using bluetooth low-energy in java language not android
|
|
|
|
|
|
i want to know what causes serialization to do ?what is the loss if we dont use serialization in java?
|
|
|
|
|
|
Hey, I am new to the coding world as well as this site. I have been learning Java by myself for a few days now and wanted to make a gambling program just for fun and practice.
I am going to ask two questions, one short, and one long. I'll ask the long one first! How does my code look for a beginner? I know I haven't dipped into using multiple classes yet or anything, so how does this very basic program look?
package com.company;
import java.util.Scanner;
import java.util.Random;
public class StakingGame {
static int cashStack = 500000;
static int amountStaked;
public static void main(String[] args) {
System.out.println("Welcome to my staking game.");
while(cashStack > 0) {
amountStaked();
System.out.println("Rolling...");
whoWon();
}
System.out.println("You have no more money.");
}
public static void amountStaked() {
Scanner scan = new Scanner(System.in);
System.out.println("How much would you like to stake?");
amountStaked = scan.nextInt();
System.out.println("You have chosen to stake, " + amountStaked + "$, goodluck.");
}
public static int roll() {
Random r = new Random();
int min = 0;
int max = 100;
int rolled = r.nextInt(max-min) + min;
return rolled;
}
public static void whoWon() {
int playerRoll = roll();
int computerRoll = roll();
System.out.println("You have rolled a " + playerRoll);
System.out.println("Your oppent has rolled a " + computerRoll);
if(playerRoll > computerRoll) {
stakeWon(0);
} else if (playerRoll < computerRoll) {
stakeLost(0);
} else {
System.out.println("You guys tied.");
}
}
public static int stakeWon(int newAmount) {
newAmount = cashStack + amountStaked;
cashStack = newAmount;
System.out.println("You have won the stake! You now have " + cashStack);
return cashStack;
}
public static int stakeLost(int newAmount) {
newAmount = cashStack - amountStaked;
cashStack = newAmount;
System.out.println("You have lost the stake.. You now have " + cashStack);
return cashStack;
}
}
My second question is, well, more of a question. I want this program to run until I either terminate it or the player runs out of money. So this is how I decided to go about that. I created this loop in my main method,
public static void main(String[] args) {
System.out.println("Welcome to my staking game.");
while(cashStack > 0) {
amountStaked();
System.out.println("Rolling...");
whoWon();
}
System.out.println("You have no more money.");
}
Is that the best way to make the program run until you either lose or I terminate it??
Thankk you in advance!
|
|
|
|
|
1. The code looks OK but I have not run it to see if it works correctly.
2. That is a generally correct way to do what you want.
If you want to find more samples and guidance then The Java Tutorials[^] is a great place for learning.
|
|
|
|
|
CoderKlip wrote: Is that the best way to make the program run until you either lose or I terminate it??
You probably want the user to terminate it by typing something normal like '0' or 'quit'.
|
|
|
|
|
1. As you said you're new here, your code looks good comparable to other noobies, the indentations look perfectly professional.
2. You should use do-while loop in your code that after every round the code asks you to continue or not, terminating will be a little unsatisfying way to end a game.
|
|
|
|
|
------------
public String getLogin(StudentTO sto)
{
String u=sto.getUsername();
String p=sto.getPassword();
System.out.println(sto.getUsername());
System.out.println(sto.getPassword());
String sql="select * from studentstable";
System.out.println(sql);
Object obj=JdbcTemplate.queryForObject(sql, new RowMapper() {
public Object mapRow(ResultSet rs) throws SQLException {
rs.beforeFirst();
while (rs.next()) {
String userdb=rs.getString("username");
String passdb=rs.getString("password");
String roledb=rs.getString("role");
String string="";
if(userdb.equals(u) && passdb.equals(p) && roledb.equalsIgnoreCase("admin")) {
System.out.println("ADMIN_ROLE");
string="ADMIN";
return string;
}else if(userdb.equals(u) && passdb.equals(p) && roledb.equalsIgnoreCase("user")) {
System.out.println("USER_ROLE");
string="USER";
return string;
}
------------------ after this code the return statement is not coming as object-------------------
Object obj=string;
}
return obj; <-------------------------------------------
}
});
StudentTO sto1=(StudentTO)obj;
System.out.println(sto1);
return sto1.toString();
}
i only want my method String getLogin() to give m result as ADMIIN or USER
modified 15-Jul-17 16:11pm.
|
|
|
|
|
You are replacing obj each time round the loop, so if it finds a record that does not contain the correct values, then obj will refer to an empty string. When you find a matching set of values you should break out of the loop.
|
|
|
|
|
can you tell m to write code in a correct way
|
|
|
|
|
You just need to add a break statement in the two if clauses when you set the string value to "USER" or "ADMIN".
|
|
|
|
|
thnks for the reply but i had solved my prblm with myself.
actually ur ans is not a correct solution buy the way thnxxx
|
|
|
|
|
LOKENDRA YADAV wrote: actually ur ans is not a correct solution buy the way thnxxx The way your code is formatted and broken up in your question it is far from easy to understand, so I had to make a guess.
|
|
|
|
|
|
hi everybody,
i need help in video tracking.Fisrt of all i wanna make gui which shows video(any format) and slider to display with buttons aside which select file and extract the video.Example like this website page
Extract Frames from Video Files[^]
i wanna do like this display in java.Please help me
|
|
|
|
|