如果我有这个代码
local f = io.open("../web/", "r")
print(io.type(f))
-- output: file
Run Code Online (Sandbox Code Playgroud)
我如何知道是否f指向某个目录?
我有这个代码
byte[] b = new byte[]{-33,-4,20,30};
System.err.println(Arrays.toString(b));
int x = (b[0] << 24) + (b[1] << 16) + (b[2] << 8) + b[3];
b = new byte[]{(byte)(x >> 24), (byte)(x >> 16), (byte)(x >> 8), (byte)(x)};
System.err.println(Arrays.toString(b));
Run Code Online (Sandbox Code Playgroud)
输出:
[-33, -4, 20, 30]
[-34, -4, 20, 30]
Run Code Online (Sandbox Code Playgroud)
我无法弄清楚为什么这个操作不是反转的.
最近我发现了ActiveObejcts,我真的很喜欢它。现在我使用的是 Atlassian 插件的最后一个版本,只有net.java.aoORM的部分。编译并运行良好。当然,如果它符合我的要求,我必须做一些性能测试。
存在@Implementation注释。那是怎么用的?javadoc 非常简短。
更新
解决方案:
public class M5 {
public static void main(String[] args) throws SQLException {
EntityManager m = EntityManagerBuilder
.url("jdbc:hsqldb:./db/db")
.username("root")
.password("")
.c3po()
.build();
m.migrate(Employee.class);
Employee p = m.create(Employee.class);
p.setFirstName("Peter");
p.setLastName("Mmm");
System.err.println(p.getLastName()); // prints "ln: Mmm"
p.save();
}
}
public class Emp {
private Employee employee;
public Emp(Employee employee) {
this.employee = employee;
}
public String getLastName() {
return "ln: " + employee.getLastName();
}
}
@Implementation(Emp.class)
interface Employee extends Entity …Run Code Online (Sandbox Code Playgroud) 我想比较 shell 脚本 (sh) 中的两个数值,但它不起作用:
#!/bin/sh
let a=30
let b=100
let x=$a-$b
echo $a $b $x
[ $a < $b ] && { echo ok; }
Run Code Online (Sandbox Code Playgroud)
输出:
30 100 -70
./x: line 6: 100: No such file or directory
Run Code Online (Sandbox Code Playgroud) 我需要一些方向来解决以下问题:
我有很多InDesign文件,我必须设置一个过程来跟踪某个段落或文本块是否在文件的不同版本之间发生了变化.如果文本块已更改,我想以"可移植"格式(html,pdf,txt)提取该文本块.
我想获取当前的 git 分支名称以使用包含分支名称的文件名构建二进制文件。在 Netbeans(7.1) 中使用 ant 可以吗?
在Postgresql 8中为什么这样可以
select * from prod where code like '1%'
select * from prod where code like '%1'
Run Code Online (Sandbox Code Playgroud)
但这会返回0行(有代码以数字1开头/结尾)
select * from prod where code like '1%1'
Run Code Online (Sandbox Code Playgroud)
更新
这发生在我目前的安装中:
# psql --version
psql (PostgreSQL) 8.3.7
create table a(code char(10));
CREATE TABLE
db=# insert into a values('111');
INSERT 0 1
db=# select * from a where code like '1%';
code
------------
111
(1 row)
db=# select * from a where code like '%1';
code
------
(0 rows)
db=# select * from …Run Code Online (Sandbox Code Playgroud) (我重写了原来的问题。问题是一样的。)
上面的示例代码不打印图像。它出现在窗口中但不打印。
public static void main(String[] args) {
final JEditorPane ed = new JEditorPane(
"text/html",
"<p>Test<br><img src='http://www.google.es/images/logos/ps_logo2.png'></p>");
JFrame f = new JFrame();
f.setLayout(new BorderLayout());
f.add(ed);
JButton b = new JButton("Print");
f.add(b,BorderLayout.SOUTH);
b.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
try {
ed.print();
} catch (PrinterException ex) {
System.err.println(ex);
}
}
});
f.pack();
f.setVisible(true);
}
Run Code Online (Sandbox Code Playgroud) 考虑以下代码
public class A {
public static void main(String[] args) {
new A().main();
}
void main() {
B b = new B();
Object x = getClass().cast(b);
test(x);
}
void test(Object x) {
System.err.println(x.getClass());
}
class B extends A {
}
}
Run Code Online (Sandbox Code Playgroud)
我期望输出"A级",但我得到"A级B级".
有没有办法将对象x转换为A.class,所以当在方法调用中使用时,运行时会认为x是A.class?
我在java中有两个字符串:
s1 = "-7ff9";
s2 = "-7ff9";
Run Code Online (Sandbox Code Playgroud)
我从服务器的响应中获取s2字符串.相反,字符串s1是参数的值.当我问:
if(s1.equals(s2)){ System.out.println("YES");}
else System.out.println("NO");
Run Code Online (Sandbox Code Playgroud)
我得到的答复是NO.
然后我比较了字符串:
System.out.println(s1.compareTo(s2));
Run Code Online (Sandbox Code Playgroud)
我得到一个 19输出,这意味着"字符串s1按字典顺序大于字符串参数s2"
我只是不知道如何解决这个问题......
java ×5
ant ×1
byte ×1
casting ×1
git ×1
lua ×1
netbeans-7 ×1
orm ×1
postgresql ×1
printing ×1
reflection ×1
shell ×1
sql-like ×1
string ×1
swing ×1