我设法旋转图像,180 degrees但希望旋转它90 degrees clockwise可以有人编辑我的代码,以便它做到这一点解释.谢谢.
private void rotateClockwise()
{
if(currentImage != null){
int width = currentImage.getWidth();
int height = currentImage.getHeight();
OFImage newImage = new OFImage(width, height);
for(int y = 0; y < height; y++) {
for(int x = 0; x < width; x++) {
newImage.setPixel( x, height-y-1, currentImage.getPixel(x, y));
}
}
currentImage = newImage;
imagePanel.setImage(currentImage);
frame.pack();
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个代码用于将文本添加到现有的.doc文件中,它将使用apache POI将其保存为另一个名称.
以下是我到目前为止尝试过的代码
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import org.apache.poi.xwpf.model.XWPFHeaderFooterPolicy;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFFooter;
import org.apache.poi.xwpf.usermodel.XWPFTable;
public class FooterTableWriting {
public static void main(String args[])
{
String path="D:\\vignesh\\AgileDocTemplate.doc";
String attch="D:\\Attach.doc";
String comment="good";
String stat="ready";
String coaddr="xyz";
String cmail="abc@gmail.com";
String sub="comp";
String title="Globematics";
String cat="General";
setFooter(path, attch, comment, stat, coaddr, cmail, sub, title, cat);
}
private static void setFooter(String docTemplatePath,String attachmentPath,String comments,String status,String coAddress,String coEmail,String subject,String title,String catagory)
{
try{
InputStream input = new FileInputStream(new File(docTemplatePath));
XWPFDocument document=new …Run Code Online (Sandbox Code Playgroud) 我现在正在进行嵌入式自适应预批准支付,我面临的问题是如何使用灯箱实现预先批准付款.
我已经通过使用灯箱设置paykey来实现付费操作,但它的工作正常,但同样我所遵循的事情,在预先批准请求的代码中几乎没有修改是没有工作灯箱得到挂起.请让我知道我在这里失踪了什么.
HTML代码:
<html>
<head>
<script src="https://www.paypalobjects.com/js/external/dg.js" type="text/javascript"></script>
</head>
<body>
<form action="https://www.sandbox.paypal.com/webapps/adaptivepayment/flow/preapprovalkey" target="PPDGFrame" class="standard">
<label for="buy">Buy Now:</label>
<input type="image" id="submitBtn" value="Pay with PayPal" src="https://www.paypalobjects.com/en_US/i/btn/btn_paynowCC_LG.gif">
<input id="type" type="hidden" name="expType" value="light">
<input id="preapprovalkey" type="hidden" name="preapprovalkey" value="{{preapprovalkey}}">
</form>
<script type="text/javascript" charset="utf-8">
var dgFlow = new PAYPAL.apps.DGFlow({ trigger: 'submitBtn' });
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) 当用户点击按钮时,客户端浏览器上的windchill GUI应该在他的系统上下载特定的pdf文件.我已经通过使用以下代码实现了这一点.
<body>
<%
String pdfname= session.getAttribute("pdfname").toString();
String Pdfpath= session.getAttribute("pdfpath").toString();
File f =new File(Pdfpath);
Boolean flag=false;
if(f.exists())
{
BufferedInputStream filein = null;
BufferedOutputStream out2=null;
try {
File file = new File(Pdfpath);//specify the file path
byte b[] = new byte[1048576];
int len = 0;
filein = new BufferedInputStream(new FileInputStream(file));
out2=new BufferedOutputStream(response.getOutputStream());
response.setHeader("Content-Length", ""+file.length());
response.setContentType("application/pdf");
response.setHeader("Content-Disposition","attachment;filename="+pdfname);
response.setHeader("Content-Transfer-Encoding", "binary");
while ((len = filein.read(b)) > 0) {
out2.write(b, 0, len);
out.println("Your Pdf Document Is Generated Please close it");
}
filein.close();
out2.flush();
out2.close();
}
catch(Exception …Run Code Online (Sandbox Code Playgroud) 我有两个HashMaps.
HashMap<String, String> hMap=new HashMap<String, String>();
hMap.put("1","one");
hMap.put("2", "two");
hMap.put("3", "three");
hMap.put("4", "four");
HashMap<String, String> hMap2=new HashMap<String, String>();
hMap2.put("one", "");
hMap2.put("two", "");
Run Code Online (Sandbox Code Playgroud)
我想比较hMap2的关键字与hMap不相等,我需要把它放在另一个hashMap中.为此,我试过这样的事情.
HashMap<String, String> hMap3=new HashMap<String, String>();
Set<String> set1=hMap.keySet();
Set<String> set2=hMap2.keySet();
Iterator<String> iter1=set1.iterator();
Iterator<String> iter2=set2.iterator();
String val="";
while(iter1.hasNext()) {
val=iter1.next();
System.out.println("key and value in hmap is "+val+" "+hMap.get(val));
iter2=set2.iterator();
while(iter2.hasNext()) {
String val2=iter2.next();
System.out.println("val2 value is "+val2);
if(!hMap.get(val).equals(val2)) {
hMap3.put(val, hMap.get(val));
System.out.println("value adding");
}
}
}
System.out.println("hashmap3 is "+hMap3);
Run Code Online (Sandbox Code Playgroud)
我得到的输出是
hashmap3 is {3=three, 2=two, 1=one, 4=four}
Run Code Online (Sandbox Code Playgroud)
我的预期输出是 …
我有一个HashMap.
Map<String,String> lhm = new HashMap<String,String>();
lhm.put("Zara", "biu");
lhm.put("Mahnaz", "nuios");
lhm.put("Ayan", "sdfe");
lhm.put("Daisy", "dfdfh");
lhm.put("Qadir", "qwe");
Run Code Online (Sandbox Code Playgroud)
我想根据属性文件中给出的顺序对该hashmap进行排序.实际上,该属性条目将按某种顺序具有键.我的属性条目将如下所示
seq=Ayan,Zara,Mahnaz,Qadir,Daisy
Run Code Online (Sandbox Code Playgroud)
我对此尝试的是
Map<String,String> lhm = new HashMap<String,String>();
Properties prop=new Properties();
prop.load(new FileInputStream("D:\\vignesh\\sample.properties"));
// Put elements to the map
lhm.put("Zara", "biu");
lhm.put("Mahnaz", "nuios");
lhm.put("Ayan", "sdfe");
lhm.put("Daisy", "dfdfh");
lhm.put("Qadir", "qwe");
// Get a set of the entries
Set<Entry<String, String>> set = lhm.entrySet();
// Get an iterator
Iterator<Entry<String, String>> iter = set.iterator();
// Display elements
String sequence=prop.getProperty("seq");
System.out.println("sequence got here is "+sequence);
String[] resultSequence=sequence.split(","); …Run Code Online (Sandbox Code Playgroud) 我有一个这样的字符串String no1="c1245_f5";,我有另一个像这样的字符串String no2="456df";,我想用第二个字符串替换第一个字符串,但仅在第一个字符后.
在这之后我在c之后更换.我的输出必须像c456df.我不知道这样做.我试着更换整个字符串
String no2="456df";
String no1="c1245_f5";
int g;
g=no1.indexOf("c");
int h=no1.indexOf("_", g+1);
no1=no1.substring(g, h);
System.out.println("Number-"+no1);
String rep=no1.replaceAll(no1,no2);
System.out.println(rep);
Run Code Online (Sandbox Code Playgroud)
这里的输出只是第二个字符串.
编辑:
预期产出:
c456df
Run Code Online (Sandbox Code Playgroud)
我得到的输出:
456df
Run Code Online (Sandbox Code Playgroud) java ×6
hashmap ×2
apache-poi ×1
comparison ×1
doc ×1
image ×1
javascript ×1
jsp ×1
lightbox ×1
outputstream ×1
paypal ×1
replace ×1
servlets ×1
string ×1