嗨...我搜索了网站,发现另一个正常工作的代码.
现在我有另一个问题:
当我从blow类创建对象并将音频地址发送到其构造函数时,我必须发送完整的地址,如:
"C:\ Documents and Settings\TheHero\My Documents\NetBeansProjects\project1\src\project1\s1.wav"
但我想使用这个代码只是声音的名称:"s1.wav".
我复制的声音进入src文件夹,然后使用"s1.wav",结果是"java.io.FileNotFoundException".
如果我使用完整的声音地址,当我在另一台计算机上运行该程序时,它不起作用.我是正确的?
//**************
公共类MusicPlayer {
private String filename;
public MusicPlayer(String filename) {
this.filename = filename;
}
public void play() {
try {
InputStream in = new FileInputStream(filename);
AudioStream as = new AudioStream(in);
AudioPlayer.player.start(as);
} catch (IOException e) {
e.printStackTrace();
}
}
Run Code Online (Sandbox Code Playgroud)
//************
我对图像有同样的问题.当我使用这些代码时,我必须使用完整的图像地址
File input = new File(imageName);
image = ImageIO.read(input);
Run Code Online (Sandbox Code Playgroud)
请有人帮助我!我真的需要这些!谢谢大家......
我想知道是否可以使用.htaccess重写文件夹名称.我的意思是这个.
可以说我有一个网址:
www.site.com/folder1/page.php
Run Code Online (Sandbox Code Playgroud)
现在我想重写网址(例如)
www.site.com/apple/page.php
Run Code Online (Sandbox Code Playgroud)
folder1是我的网站空间上的现有文件夹.
重要的是:"苹果"不是一个文件夹,而只是一个名字!
好的,这是一步一步的计划:
www.site.com/folder1/login.phpwww.site.com/apple/login.php这意味着它apple只是一个名称而不是目录.所有代码都应该来自folder1.苹果应该只是一个别名folder1.我不能只重命名folder1来Apple.为此我只想改写folder1到apple.
可能重复:
(0 ==变量)或(null == obj):C#中过时的练习?
为什么在C#中经常会看到"null!= variable"而不是"variable!= null"?
我见过很多次人们将null评估为变量而不是将变量评估为null.
if(null== user)
Run Code Online (Sandbox Code Playgroud)
代替
if(user==null)
Run Code Online (Sandbox Code Playgroud)
我知道两者都试图实现相同的功能.所以,它是一些标准还是纯粹的个人偏好.请评论.
我想编写将输出的代码:
length [1,2,3] => 3
Run Code Online (Sandbox Code Playgroud)
在Ruby中,我可以这样做:
puts "length [1,2,3] => #{[1,2,3].length}"
Run Code Online (Sandbox Code Playgroud)
以下尝试是Haskell失败了......
Prelude Data.List> print "length [1,2,3]"
"length [1,2,3]"
Prelude Data.List> print (length [1,2,3])
3
Prelude Data.List> print "length [1,2,3]" (length [1,2,3])
<interactive>:1:0:
Couldn't match expected type `Int -> t'
against inferred type `IO ()'
In the expression: print "length [1,2,3]" (length [1, 2, 3])
In the definition of `it':
it = print "length [1,2,3]" (length [1, 2, 3])
Prelude Data.List>
Run Code Online (Sandbox Code Playgroud) 使用ruby,露营webframework,activerecord-2.1.1,我的db结构是......
create_table :Conf_posts do |t|
%w{title body username posttime hit passwd}.each do |col|
t.column :"#{col}", :string
end
end
Run Code Online (Sandbox Code Playgroud)
我想要每个用户名的总和
我有以下代码.
Post.find :all, :select => "username,sum(hit)", :from => "Conf_posts", :group => "username"
Run Code Online (Sandbox Code Playgroud)
我收到了以下结果.仅返回用户名:
[#<Conf::Models::Post username: "\352\260\225\355\230\201">, #<Conf::Models::Post username: "\353\215\225\352\267\234">, #<Conf::Models::Post username: "\353\225\214\355\230\270">, #<Conf::Models::Post username: "\353\263\264\353\236\214">, #<Conf::Models::Post username: "\354\230\201\352\262\275">, #<Conf::Models::Post username: "\354\232\260\353\236\214">, #<Conf::Models::Post username: "\354\235\270\354\204\235">, #<Conf::Models::Post username: "\354\240\225\355\231\224.">, #<Conf::Models::Post username: "\355\230\201\354\235\264">]
Run Code Online (Sandbox Code Playgroud)
我无法同时收到用户名和用户名的总和
在调查Ruby时,我遇到了这个问题来创建一个类似Struct的类:
Person = Struct.new(:forname, :surname)
person1 = Person.new('John', 'Doe')
puts person1 #<struct Person forname="John", surname="Doe">
Run Code Online (Sandbox Code Playgroud)
这为我提出了一些Python问题.我在Python中编写了一个[非常]基本的克隆机制:
def Struct(*args):
class NewStruct:
def __init__(self):
for arg in args:
self.__dict__[arg] = None
return NewStruct
>>> Person = Struct('forename', 'surname')
>>> person1 = Person()
>>> person2 = Person()
>>> person1.forename, person1.surname = 'John','Doe'
>>> person2.forename, person2.surname = 'Foo','Bar'
>>> person1.forename
'John'
>>> person2.forename
'Foo'
Run Code Online (Sandbox Code Playgroud)
Python中是否已有类似的机制来处理这个问题?(我通常只使用字典).
我如何获得Struct()创建正确__init__()参数的函数.(在这种情况下,我想尽可能执行person1 = Person('John', 'Doe')命名参数:person1 = Person(surname='Doe', forename='John')
我想,感兴趣的是,即使有更好的Python机制来解决问题2也是如此.
我在当前的Zend Framework应用程序中遇到了问题.
在我的Bootstrap中,我注册了以下路线:
protected function _initRouter()
{
$this->bootstrap("FrontController");
$frontController = $this->getResource("FrontController");
$route = new Zend_Controller_Router_Route(
":module/:id",
array(
"controller" => "index",
"action" => "index"
),
array("id" => "\d+")
);
$frontController->getRouter()->addRoute('shortcutOne', $route);
$route = new Zend_Controller_Router_Route(
":module/:controller/:id",
array("action" => "index"),
array("id" => "\d+")
);
$frontController->getRouter()->addRoute('shortcutTwo', $route);
$route = new Zend_Controller_Router_Route(
":module/:controller/:action/:id",
null,
array("id" => "\d+", "action" => "\w+")
);
$frontController->getRouter()->addRoute('shortcutThree', $route);
}
Run Code Online (Sandbox Code Playgroud)
后来我将Zend_Navigation添加到我的项目中.我有几个模块,在模块引导程序中注册导航元素:
<?php
class Contact_Bootstrap extends Zend_Application_Module_Bootstrap
{
protected function _initNavigation()
{
$layout = $this->getApplication()->getResource("layout");
$view = $layout->getView();
$config = new …Run Code Online (Sandbox Code Playgroud) 我的目标是分析一些语料库(现在的推特)的情感内容.就在今天,我意识到搜索词干会有一点意义,而不是有一个详尽的情感词干列表.所以我一直在探索nltk.stem,只是意识到有4种不同的词干分析器.我想问一下stackoverflow语言学家,LancasterStemmer,PorterStemmer,RegexpStemmer,RSLPStemmer或WordNetStemmer是否最好有一些理由.
使用以下简单代码:
package test;
import java.io.*;
import javax.xml.transform.*;
import javax.xml.transform.stream.*;
public class TestOutputKeys {
public static void main(String[] args) throws TransformerException {
// Instantiate transformer input
Source xmlInput = new StreamSource(new StringReader(
"<!-- Document comment --><aaa><bbb/><ccc/></aaa>"));
StreamResult xmlOutput = new StreamResult(new StringWriter());
// Configure transformer
Transformer transformer = TransformerFactory.newInstance()
.newTransformer(); // An identity transformer
transformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, "testing.dtd");
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.transform(xmlInput, xmlOutput);
System.out.println(xmlOutput.getWriter().toString());
}
}
Run Code Online (Sandbox Code Playgroud)
我得到输出:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Document comment --><!DOCTYPE aaa SYSTEM "testing.dtd">
<aaa>
<bbb/>
<ccc/>
</aaa>
Run Code Online (Sandbox Code Playgroud)
问题A:doctype标签出现在文档注释之后.是否有可能在文件评论之前出现?
问题B:如何仅使用JavaSE 5.0 …