小编Mic*_*ift的帖子

写入文件:IOException:流已关闭

我无法弄清楚为什么我的代码会出现上述错误。每次调用该方法时,我都会创建 FileWriter 和 BufferedWriter 的新实例,但显然流已经关闭。

public static void addSpawn(Location spawn)
{
    File spawns = new File("spawns.dat");

    FileWriter write = null;
    BufferedWriter out = null;

    try
    {
        write = new FileWriter(spawns, true);
        out = new BufferedWriter(write);

        out.write(locToStr(spawn));
        out.newLine();
    }
    catch(Exception e)
    {
        System.out.println("Error writing spawn file: " + e.getMessage());
    }
    finally
    {
        if(write != null)
        {
            try
            {
                write.close();
            }
            catch(Exception e)
            {
                e.printStackTrace();
            }
        }

        if(out != null)
        {
            try
            {
                out.close();
            }
            catch(Exception e)
            {
                e.printStackTrace();
            }
        }
    } …
Run Code Online (Sandbox Code Playgroud)

java ioexception filewriter

2
推荐指数
1
解决办法
7088
查看次数

C++/OpenGL | "未定义引用`_imp__ChoosePixelFormat @ 8`"等等

我正在阅读NeHe的第一个OpenGL编程指南,当它编写完成他的第一个教程的结果时,我很难找到错误.这是发生错误的整个源文件(在Eclipse CDT中创建,'opengl32''glaux''glug32''glu32'成功链接):

#include <windows.h>
#include <gl/gl.h>
#include <gl/glu.h>
#include <gl/glaux.h>
#define GLEW_STATIC

HGLRC hRC = NULL;
HDC hDC = NULL;
HWND hWnd = NULL;
HINSTANCE hInstance;

bool keys[256];
bool active = TRUE;
bool fullscreen = TRUE;

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

GLvoid ResizeGLScene(GLsizei width, GLsizei height)
{
    if(height == 0) height = 1;

    glViewport(0, 0, width, height);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();

    gluPerspective(45.0f, (GLfloat) width / (GLfloat) height, 0.1f, 100.0f);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
}

int InitGL()
{
    glShadeModel(GL_SMOOTH);
    glClearColor(0, 0, 0, 0);
    glClearDepth(1); …
Run Code Online (Sandbox Code Playgroud)

c++ eclipse windows opengl eclipse-cdt

2
推荐指数
1
解决办法
3226
查看次数

标签 统计

c++ ×1

eclipse ×1

eclipse-cdt ×1

filewriter ×1

ioexception ×1

java ×1

opengl ×1

windows ×1