有没有办法可以覆盖System.out.print()的输出.这是我想做的事情?System.out.print("ABCDEFGHIJK L"); 将打印:ABCDEFGHIJKL
现在我想编写一个方法来覆盖特定位置的输出.覆盖(7,"XY Z"); 应输出我,ABCXYZGHIJKL
这些应该发生在控制台中.
请帮忙.谢谢
我试图从iframe中关闭FancyBox,但parent.$
总是如此undefined
.这是我的iframe JavaScript:
<script type='text/javascript'
src='http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js'>
</script>
<script type="text/javascript">
jQuery(document).ready(function($){
(function($) {
$.fn.closeFancyBox = function() {
$(this).click(function() {
parent.$.fancybox.close();
});
};
})(jQuery);
$('#cancel').closeFancyBox();
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
更换parent.$.fancybox.close();
用alert('clicked');
的作品就好了.我不明白为什么parent.$
是undefined
当iframe是在同一个域中.
我正在使用WordPress 2.9.1和FancyBox for Wordpress插件.
//server.local/web/test/index.php
//server.local/web/test/wp-content/plugins/wp-test/test.htm
这些网址中的第一个是主页面,第二个是iframe页面; server.local
是我的家庭测试服务器.
有任何想法吗?如果它有用,我可以将整个源代码粘贴.
我的一位同学刚问过我,我完全失去了.Google给了我很多关于endian-ness的定义,但没有给出这个特殊情况的术语.甚至有一个术语吗?
我想在java中使用多行字符串,所以我寻求一个简单的预处理器来将C风格的多行转换为带有文字'\n'的单行.
之前:
System.out.println("convert trailing backslashes\
this is on another line\
\
\
above are two blank lines\
But don't convert non-trailing backslashes, like: \"\t\" and \'\\\'");
Run Code Online (Sandbox Code Playgroud)
后:
System.out.println("convert trailing backslashes\nthis is on another line\n\n\nabove are two blank lines\nBut don't convert non-trailing backslashes, like: \"\t\" and \'\\\'");
Run Code Online (Sandbox Code Playgroud)
我认为sed
会做得很好,但是sed是基于行的,所以替换'\'和它后面的换行符(有效加入两行)在sed中并不是很自然.我将sredden79的oneliner改编为以下 - 它有效,它很聪明,但不清楚:
sed ':a { $!N; s/\\\n/\\n/; ta }'
Run Code Online (Sandbox Code Playgroud)
替补是escaped literal backslash
,newline
有escaped literal backslash
,n
. :a
是标签,ta
如果替代品找到匹配,则为goto标签; $
表示最后一行,并且$! …
以下在CFMX 7和CF8中工作正常,我也假设CF9:
<!--- 'conn' is a JDBC connection --->
<cfset stat = conn.createStatement() />
<cfset rs = stat.executeQuery(trim(arguments.sql)) />
<!--- convert this Java resultset to a CF query recordset --->
<cfset queryTable = CreateObject("java", "coldfusion.sql.QueryTable")>
<cfset queryTable.init(rs) >
<cfset query = queryTable.FirstTable() />
Run Code Online (Sandbox Code Playgroud)
这将使用JDBC驱动程序创建一个语句,对它执行查询,将其放入java结果集,然后实例化coldfusion.sql.QueryTable,传递Java resulset对象,然后调用queryTable.FirstTable(),返回实际的coldfusion结果集(用于cfloop等).
问题在于Railo的实施有所不同.在Railo中运行此代码会返回以下错误:找不到匹配的coldfusion.sql.QueryTable(org.sqlite.RS)构造函数.
我已经转储了Railo java对象,并且在方法中没有看到init().我错过了一些简单的事吗?我也很想在Railo工作.
请注意:我正在与SQLite数据库建立无DSN连接.我了解如何设置CF数据源.我在这一点上唯一的打嗝是从Java结果集转换为Railo查询.
我正在学习蟒蛇。我喜欢使用 help() 或 interinspect.getargspec 来获取 shell 中的函数信息。但是无论如何我可以获得函数的参数/返回类型。
我阅读了一个教程,它使用SQLlite和"SimpleCursorAdapter"来填充列表中的项目.这是教程教给我的代码.
private void fillData() {
// Get all of the notes from the database and create the item list
Cursor c = mDbHelper.fetchAllNotes();
startManagingCursor(c);
String[] from = new String[] { NotesDbAdapter.KEY_TITLE };
int[] to = new int[] { R.id.text1 };
// Now create an array adapter and set it to display using our row
SimpleCursorAdapter notes =
new SimpleCursorAdapter(this, R.layout.notes_row, c, from, to);
setListAdapter(notes);
}
Run Code Online (Sandbox Code Playgroud)
但是......如果我想用XML数据填充它会怎么样?它是一样的方法吗?有人可以给我一个例子(代码中)吗?谢谢.
我想知道Python内置容器(list,vector,set ...)是否是线程安全的?或者我是否需要为共享变量实现锁定/解锁环境?
有没有办法找出Linux bash脚本中的文件的MIME类型(或称为"Content-Type"?)?
我需要它的原因是因为ImageShack似乎需要它来上传文件,因为它将某个.png文件检测为application/octet-stream
文件.
我检查了文件,它确实是一个PNG图像:
$ cat /1.png
?PNG
(with a heap load of random characters)
Run Code Online (Sandbox Code Playgroud)
这给了我错误:
$ curl -F "fileupload=@/1.png" http://www.imageshack.us/upload_api.php
<links>
<error id="wrong_file_type">Wrong file type detected for file 1.png:application/octet-stream</error>
</links>
Run Code Online (Sandbox Code Playgroud)
这有效,但我需要指定MIME-TYPE.
$ curl -F "fileupload=@/1.png;type=image/png" http://www.imageshack.us/upload_api.php
Run Code Online (Sandbox Code Playgroud)